English 中文(简体)
Levenshtein 距离和特殊字符
原标题:Levenshtein distances and special characters

I have implemented a Levenshtein distance algorithm using a trie tree, as described here by Steve Hanov. However, I m having difficulty handling special characters. For instance, if I calculate the distance between Großmann and Grossmann, I need the distance to be zero, since ß and ss should be considered equal.

支持这些特殊情况的最佳解决办法(如果有的话)是什么?

My initial thought was to kind of normalize all strings before calculating the distance. So in Großmann -> Grossman, österreich -> oesterreich, ... However, there seems to be no such functionality in .NET?

最佳回答

目前的挑战是,目前的文化没有确定单词的语言。

假设你愿意在匹配的一方出错

确定一组不需要绘制的字符 。

为所有文化绘制一套地图。

确定特定文化的分布图。

首先做一个未绘制的莱文什丁距离。

如果未测量的距离为零,则停止。

如果未测量的距离大于 x (例如 4), 则停止, 因为它不匹配 。

如果单词只有不需要绘制的字符( 如 a- z), 那么停止 。

地图既覆盖所有文化,也覆盖所有文化,如果距离是零停止。

默认文化的地图,如果距离为零停止,则地图。

地图是其他文化的地图,如果距离是零停止。

我加了一个直线字符串 向莱文什丁号报告如果是真的0

问题回答

我认为正常化是前进的道路。

我并不知道有哪个图书馆 做这个现成的, 和快速搜索 没有发现任何东西。

在此讨论一个类似的问题:将“Bizarre”字符字符串转至罗马Chars

只要能提前全面确定所有必要的地图, 手工绘制地图的解决方案就会有效。





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签