Text completion: Difference between revisions
m
→{{header|Phix}}: use apply()/calc once
m (C++ - reject empty word) |
m (→{{header|Phix}}: use apply()/calc once) |
||
Line 479:
=={{header|Phix}}==
uses levenshtein() from [[Levenshtein_distance#Phix]] and [http://wiki.puzzlers.org/pub/wordlists/unixdict.txt this unixdict.txt]
▲uses levenshtein() from [[Levenshtein_distance#Phix]] and [http://wiki.puzzlers.org/pub/wordlists/unixdict.txt unixdict] (not the same as the one Julia uses - I did just check and indeed it does ''not'' have "collection" in it!)
<lang Phix>string word = "complition"
sequence words = get_text(join_path({"demo","unixdict.txt"}),GT_LF_STRIPPED),
leven = apply(words,levenshtein,word)
function
for n=1 to 4 do
printf(1,"Words at Levenshtein distance of %d (%g%% similarity) from \"%s\": \n%s\n",
{n,100-round(100*n/length(word)),word,join_by(filter(words,
end for</lang>
{{out}}
(matches Delphi/Go/Wren)
<pre>
Words at Levenshtein distance of 1 (90% similarity) from "complition":
|