如何搜索类似的单词

时间:2022-09-13 09:36:06

I have a record file and I need to make a program that should help find any word into that record by typing a word into a search field. The record file contains a list of words so I need to search into that list to find any word that could be similar to my word.

我有一个记录文件,我需要制作一个程序,通过在搜索字段中输入一个单词来帮助找到该记录中的任何单词。记录文件包含单词列表,因此我需要搜索该列表以查找可能与我的单词类似的任何单词。

I am using Delphi 2007

我正在使用Delphi 2007

3 个解决方案

#1


Delphi 2007 should have a number of string matching routines in StrUtils that use the Soundex algorithm to find similar "sounding" words. Depending on how your file is formatted you may be able to load it into a TStringList then in the OnChange event handler of your input field call a routine that iterates through the list and performs a soundex comparison with the user's input and each entry in the list.

Delphi 2007应该在StrUtils中有许多字符串匹配例程,它们使用Soundex算法来查找类似的“发声”字。根据文件格式的格式,您可以将其加载到TStringList中,然后在输入字段的OnChange事件处理程序中调用一个例程,该例程遍历列表并执行与用户输入和列表中每个条目的soundex比较。

Look at ResemblesText, SoundexCompare, SoundexProc and SoundexSimilar. One of those should get you going.

看看ResemblesText,SoundexCompare,SoundexProc和SoundexSimilar。其中一个应该让你去。

#2


A Levenshtein distance algorithm can be used to calculate word differences.

Levenshtein距离算法可用于计算单词差异。

The Levenshtein distance is a metric for measuring the amount of difference between two sequences (i.e. an edit distance).

Levenshtein距离是用于测量两个序列之间的差异量(即编辑距离)的度量。

There are some Pascal implementations available in the Internet, for example

例如,Internet中有一些Pascal实现

Friends of Free pascal - http://fofpc.org/wunder/Levenshtein_Comparison

免费pascal之友 - http://fofpc.org/wunder/Levenshtein_Comparison

#3


Use a regular expression.

使用正则表达式。

www.regular-expressions.info/delphi.html

#1


Delphi 2007 should have a number of string matching routines in StrUtils that use the Soundex algorithm to find similar "sounding" words. Depending on how your file is formatted you may be able to load it into a TStringList then in the OnChange event handler of your input field call a routine that iterates through the list and performs a soundex comparison with the user's input and each entry in the list.

Delphi 2007应该在StrUtils中有许多字符串匹配例程,它们使用Soundex算法来查找类似的“发声”字。根据文件格式的格式,您可以将其加载到TStringList中,然后在输入字段的OnChange事件处理程序中调用一个例程,该例程遍历列表并执行与用户输入和列表中每个条目的soundex比较。

Look at ResemblesText, SoundexCompare, SoundexProc and SoundexSimilar. One of those should get you going.

看看ResemblesText,SoundexCompare,SoundexProc和SoundexSimilar。其中一个应该让你去。

#2


A Levenshtein distance algorithm can be used to calculate word differences.

Levenshtein距离算法可用于计算单词差异。

The Levenshtein distance is a metric for measuring the amount of difference between two sequences (i.e. an edit distance).

Levenshtein距离是用于测量两个序列之间的差异量(即编辑距离)的度量。

There are some Pascal implementations available in the Internet, for example

例如,Internet中有一些Pascal实现

Friends of Free pascal - http://fofpc.org/wunder/Levenshtein_Comparison

免费pascal之友 - http://fofpc.org/wunder/Levenshtein_Comparison

#3


Use a regular expression.

使用正则表达式。

www.regular-expressions.info/delphi.html