Skip to content

fix(tokenizers): return extractors in a stable order - #353

Open
jamalkamaladdin wants to merge 2 commits into
freelawproject:mainfrom
jamalkamaladdin:fix/issue-352
Open

jamalkamaladdin wants to merge 2 commits into
freelawproject:mainfrom
jamalkamaladdin:fix/issue-352

Conversation

@jamalkamaladdin

Copy link
Copy Markdown

Fixes

Fixes #352

Summary

AhocorasickTokenizer.get_extractors returned a set. Set order depends on PYTHONHASHSEED. For 37 T.C. at 155, one full cite token and two short cite tokens share one span. tokenize takes the first of them.

get_extractors now sorts selected extractors by their index in EXTRACTORS. Base Tokenizer uses the same order. 37 T.C. at 155 now yields a ShortCaseCitation on every seed.

New test test_extractor_order_is_stable in tests/test_TokenizeTest.py checks extractor order and the short cite token. Added a CHANGES.md entry.

AI Disclosure

  • No AI tools were used to create the content of this PR.
  • Parts of this PR were created with the help of an AI tool, and I have carefully reviewed all of its content and take full responsibility for it.

AhocorasickTokenizer.get_extractors returned a set, so extractors ran in hash order. When several extractors matched the same span, the first token won, and the result depended on PYTHONHASHSEED. Sort the selected extractors by their position in EXTRACTORS, the same order the base Tokenizer uses.

Fixes freelawproject#352

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@CLAassistant

CLAassistant commented Sep 25, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@lokkju

lokkju commented Oct 23, 2026

Copy link
Copy Markdown

Tested the head (f54f57f) against eyecite 2.7.8's 86 T.C. at 561 case: ShortCaseCitation under PYTHONHASHSEED 0 to 3, where 2.7.8 alternates with FullCaseCitation. One thought for review, detailed in #352: this makes identical-span ties reproducible, but the winner is still whichever extractor comes first in EXTRACTORS. An explicit tie-break (keep the short-cite token when a short and a full token share a span) would make the outcome principled rather than order-dependent.

This branch has not been deployed

No deployments
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.

Citation type for NN T.C. at NNN depends on the process hash seed

3 participants