Text completion: Difference between revisions
Content added Content deleted
(→{{header|REXX}}: added the computer programming language REXX.) |
|||
Line 106: | Line 106: | ||
Process finished with exit code 0 |
Process finished with exit code 0 |
||
</pre> |
</pre> |
||
=={{header|Julia}}== |
|||
See https://en.wikipedia.org/wiki/Levenshtein_distance, the number of one character edits to obtain one word from another. |
|||
<lang julia>using StringDistances |
|||
const fname = download("https://www.mit.edu/~ecprice/wordlist.10000", "wordlist10000.txt") |
|||
const words = read(fname, String) |> split .|> strip .|> string |
|||
const wrd = "complition" |
|||
levdistof(n, string) = filter(w -> Levenshtein()(string, w) == n, words) |
|||
for n in 1:4 |
|||
println("Words at Levenshtein distance of $n from \"$wrd\": ", levdistof(n, wrd), "\n") |
|||
end |
|||
</lang>{{out}} |
|||
<pre> |
|||
Words at Levenshtein distance of 1 from "complition": ["completion"] |
|||
Words at Levenshtein distance of 2 from "complition": ["coalition", "competition", "compilation", "composition"] |
|||
Words at Levenshtein distance of 3 from "complition": ["companion", "competitions", "completing", "complications", "computation", "condition"] |
|||
Words at Levenshtein distance of 4 from "complition": ["collection", "combination", "commission", "comparison", "compensation", "competing", "competitive", "complaint", "complete", "completed", "completely", "complexity", "compliance", "compliant", "compression", "computing", "conclusion", "conditions", "connection", "convention", "conviction", "cooperation", "corporation", "correction", "correlation", "corruption", "nomination", "opinion", "opposition", "option", "pollution", "population", "position", "simulation", "solution"] |
|||
</pre> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |