Fix : Decode HTML entities in author names before tokenization#4761
Open
dikshaa2909 wants to merge 1 commit intoaboutcode-org:developfrom
Open
Fix : Decode HTML entities in author names before tokenization#4761dikshaa2909 wants to merge 1 commit intoaboutcode-org:developfrom
dikshaa2909 wants to merge 1 commit intoaboutcode-org:developfrom
Conversation
…okenization Signed-off-by: dikshaa2909 <dikshadeware@gmail.com>
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.
Fixes #4760
Summary
This PR fixes incorrect author detection when author names contain HTML entities or Unicode characters (e.g.,
ü,ö,ü, etc.).Previously, author names like
Ceki Gülcü(Ceki Gülcü) were completely missed during copyright scanning because the tokenizer's proper noun (NNP) pattern did not support Unicode characters that result from HTML entity decoding.Root Cause
While HTML entities were being decoded using
html.unescape()(line 427 insrc/cluecode/copyrights.py), the resulting Unicode characters (ü, ö, ä, etc.) were not recognized by the NNP tokenizer patterns. The regex patterns[a-z0-9]+on lines 2221 and 2261 only matched ASCII lowercase letters and digits, causing names with accented characters to be misclassified as common nouns (NN) instead of proper nouns (NNP), which prevented author detection.Fix
Extended the NNP (proper noun) tokenizer patterns in
src/cluecode/copyrights.pyto support Unicode characters:r'^([A-Z][a-z0-9]+){1,2}[\.,]?$'tor'^([A-Z][a-zà-ÿ0-9]+){1,2}[\.,]?$'r'^([A-Z][a-z0-9]+){1,2}\.?,?$'tor'^([A-Z][a-zà-ÿ0-9]+){1,2}\.?,?$'This ensures:
Tests
tests/cluecode/data/authors/author_html_entity.java- now correctly detects all 3 authors includingCeki Gülcü.ymlexpected output validation passespytest tests/cluecode/test_copyrights.py --test-suite alltest_authors_author_html_entity_java_14No regressions introduced.
Checklist