Registry Mirror
Skip to content

Conversation

@bardrop

@bardrop bardrop commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Jaccard returns nan when collapsing whitespace leaves both strings shorter than k:

>>> Jaccard(4).similarity("0  s", "a  b")
nan

Both strings are 4 characters long, so they pass the length check, but the profiles of "0 s" and "a b" are empty and the union has size 0. (The Python version raised ZeroDivisionError here.)

It is 0.0 now, the same as Cosine since #37, and as SorensenDice and OverlapCoefficient. The new Rust and Python tests fail without the change.

@luozhouyang
luozhouyang merged commit 311bc9d into luozhouyang:master Nov 27, 2026
6 checks passed
luozhouyang added a commit that referenced this pull request Dec 2, 2026
- Fix Jaccard returning NaN when whitespace normalization removes every
  shingle from both inputs (#47).

Co-Authored-By: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants