Sorensen–Dice coefficient: Difference between revisions

m
m (→‎{{header|jq}}: simplify)
 
(One intermediate revision by the same user not shown)
Line 26:
SDC = 2 × |A∩B| / (|A| + |B|)
 
it being understood thatwhere A, B and A∩B are to be understood as multisets, and that if an item, x, has multiplicity a in A and b in B, then it will have multiplicity min(a,b) in A∩B.
 
The Sørensen–Dice coefficient is thus a ratio between 0.0 and 1.0 giving the "percent similarity" between the two populations.
Line 327:
| .[1] as $j
| if $i == ($A|length) or $j == ($B|length) then empty
elif $A[$i] == $B[$j] then $A[$i]1, ([$i+1, $j+1] | pop)
elif $A[$i] < $B[$j] then [$i+1, $j] | pop
else [$i, $j+1] | pop
Line 337:
# Emit a stream of the bigrams of the input string blindly
def bg: . as $in | range(0;length-1 ) | $in[.:.+2];
ascii_downcase | [splits(" *") | bg];
| reduce splits(" *") as $word ([];
. + [$word | bg]);
 
 
2,462

edits