Reputation:
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
Upvotes: 2
Views: 2167
Reputation: 36664
A Levenshtein distance algorithm can be used to calculate word differences.
The Levenshtein distance is a metric for measuring the amount of difference between two sequences (i.e. an edit distance).
There are some Pascal implementations available in the Internet, for example
Friends of Free pascal - http://fofpc.org/wunder/Levenshtein_Comparison
Upvotes: 2
Reputation: 12114
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.
Look at ResemblesText
, SoundexCompare
, SoundexProc
and SoundexSimilar
. One of those should get you going.
Upvotes: 4