Sorensen–Dice coefficient: Difference between revisions
m
→Julia
m (→Julia) |
|||
Line 203:
=={{header|Julia}}==
<syntaxhighlight lang="julia">using
""" convert a phrase into a count of bigram tokens of its words """
function tokenizetext(txt)
tokens =
words = split(lowercase(txt), r"\s+")
for w in words
if length(w) < 3
push!(tokens
else
for i in 1:length(w)-1
end
end
Line 225 ⟶ 223:
""" Sorenson-Dice similarity of multisets """
function
bc1, bc2 = tokenizetext(text1), tokenizetext(text2)
return 2 *
end
Line 235 ⟶ 233:
for test in ["Primordial primes", "Sunkist-Giuliani formula",
"Sieve of Euripides", "Chowder numbers"]
taskvalues = sort!([(
println("\n$test:")
for (val, task) in taskvalues[begin:begin+4]
Line 241 ⟶ 239:
end
end
</syntaxhighlight>{{out}}
<pre>
|