Levenshtein距离复合字母 [英] Levenshtein distance composite letters

查看:83
本文介绍了Levenshtein距离复合字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下是否有人会帮助我,我有一个使用Levenshtein距离的任务,但是像SH,DH,ZH这样的复合字母的距离应该是一个字母,这些字母在使用时的距离必须当计算levenshtein距离时,为1而不是2。

I want to ask if anyone will help me, I have a task to use Levenshtein Distance, but distance for some composite letters like SH, DH, ZH, should be as a single letter, Well distances for these letters when used must be 1 not 2 when calculates levenshtein distance.

推荐答案

对此有一个非常简单的解决方案,你根本不需要改变Levenshtein算法:在你之前计算距离,用一个不会出现在其他地方的单个字符替换那些复合材料:控制字符。例如。 ASCII 1,2,3。
There's a very easy solution for this and you don't have to change the Levenshtein-algorithm at all: Before you calculate the distance, replace those composites with a single character that won't appear anywhere else: Control characters. Eg. ASCII 1, 2, 3.


这篇关于Levenshtein距离复合字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆