Sorensen–Dice coefficient: Difference between revisions

m
→‎{{header|J}}: emphasize the likely ephemeral nature of draft commentary.
m (→‎{{header|J}}: avoid a minor bug in <syntaxhighlight lang=J>)
m (→‎{{header|J}}: emphasize the likely ephemeral nature of draft commentary.)
Line 53:
nearest=: {{ m{.\:~ x (] ;"0~ SDI) cutLF y }}</syntaxhighlight>
 
This is slightly different from the current draft task description, which suggests that <code>SDI = 2 × (A ∩ B) / (A ⊎ B)</code> produces a number between 0 and 1. If A and B are sets, each containing the same tokens, the result here would be 2 rather than 1. But we can make sense of this by assuming that the original algorithm was working with sequences rather than sets. The sequence difference is not commutative, so if <code>∩</code> represents sequence difference, and <code>⊎</code> represents sequence addition, it would make sense to define <code>SDI= ((A ∩ B) + (B ∩ A)) / (A ⊎ B)</code>, which is what we have done here.
 
With this implementation, here's the task examples:
6,962

edits