Repository navigation
FIX: keep decimal and thousands separators between digits in PlagiarismScorer tokenization - #3127
Merged
Roman Lutz (romanlutz) merged 2 commits intoOct 12, 2026
Conversation
…smScorer tokenization Separators between two decimal digits were dropped without a token boundary, so 2.5 tokenized as 25 and 25.00 and 2,500 both as 2500. Identical tokens hit the verbatim fast path and scored 1.0 on every metric. Keep . and , between digits the same way fraction slashes are kept since microsoft#3053. Closes microsoft#3126
Contributor
Author
@microsoft-github-policy-service agree |
Roman Lutz (romanlutz)
approved these changes
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #3126.
PlagiarismScorer._tokenizedropped any punctuation that is not a fraction slash without inserting a token boundary, so a decimal point or thousands separator between two digits joined the digits on either side:2.5tokenized as25, and25.00and2,500both as2500. Because reference and response then tokenized identically, the verbatim fast path returned 1.0 on all three metrics, and aFloatScaleThresholdScoreron top returnedTruefor a response that differs from the reference by a factor of ten or a hundred.This extends the digit-flanked separator rule introduced in #3053 for fractions. A new
_NUMERIC_SEPARATORStable lists the separators that are kept when they sit between two decimal digits and the form each takes in the token: both slash variants still fold to/, and.and,are kept as written. Punctuation anywhere else behaves exactly as before (a/b→ab,don't→dont, trailing2.→2), so no existing test changes.Trade-off: a response that writes
1000where the reference wrote1,000now scores slightly below 1.0 rather than matching exactly. That is the same trade #3053 made for fractions and seems right for a scorer whose job is detecting reproduction.Tests and Documentation
Two existing parametrized tests in
tests/unit/score/test_plagiarism_scorer.pygain cases:test_tokenize_fraction_and_mark_boundaries:2.5,25.00,2,500,1.2.3and fullwidth2.5each stay one token;2.,.5,2..5,a.b,a,b,1,akeep the previous behaviour.test_score_text_fraction_not_concatenated_async:2.5/25,25.00/2500,2,500/2500,25.00/2,500score 0.75 / 0.75 / 2⁄3 across LCS / Levenshtein / Jaccard andFalsethrough the threshold scorer, instead of 1.0 andTrue.With only the source change reverted the 17 new cases fail; with it they pass.
tests/unit/score: 3614 passed, 44 skipped.ruff checkandruff format --checkare clean. The_tokenizedocstring is updated; no notebook documents the tokenizer's separator handling, so no JupyText run was needed.