From 1ebd0dc2d6f00e3ff5a31d3b062f57abb60d1a1f Mon Sep 17 00:00:00 2001 From: Hrithik Sharma Date: Fri, 11 Sep 2026 15:01:54 +0530 Subject: [PATCH 1/2] Fix author detection for compact dotted names Signed-off-by: Hrithik Sharma --- src/cluecode/copyrights.py | 12 ++++++++++++ tests/cluecode/test_copyrights_basic.py | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/cluecode/copyrights.py b/src/cluecode/copyrights.py index 29876084168..155a349dbcf 100644 --- a/src/cluecode/copyrights.py +++ b/src/cluecode/copyrights.py @@ -431,6 +431,15 @@ def get_tokens(numbered_lines, splitter=re.compile(r'[\t =;]+').split): # space before in some cases: exclude (digit , (s , (c , (- # this allows to recover from words like KISA(Korean line = re.sub(pattern=r'(\([^rsc\-\d])', repl=r' \g<1>', string=line) + + # Split compact author prefixes such as Author:Frankie.Chu while + # preserving colons elsewhere, for example in URLs. + line = re.sub( + pattern=r'(^|\s)([Aa]uthor):(?=\S)', + repl=r'\1\2 ', + string=line, + ) + for tok in splitter(line): # strip trailing quotes+comma if tok.endswith("',"): @@ -1805,6 +1814,9 @@ def build_detection_from_node( # Proper Nouns ############################################################################ + # Dotted proper names such as Frankie.Chu + (r'^[A-Z][a-z]+(?:\.[A-Z][a-z]+)+$', 'NAME'), + # Title case word with a trailing parens is an NNP, including with an optional trailing period (r'^[A-Z][a-z]{3,}\)\.?$', 'NNP'), # Title case word with a leading parens is an NNP diff --git a/tests/cluecode/test_copyrights_basic.py b/tests/cluecode/test_copyrights_basic.py index 1fbafcf5488..2741dbf95d1 100644 --- a/tests/cluecode/test_copyrights_basic.py +++ b/tests/cluecode/test_copyrights_basic.py @@ -319,6 +319,22 @@ def test_detect_with_lines_only_holders(self): )) assert results == expected + def test_detect_author_without_space_and_with_dotted_name(self): + numbered_lines = [ + (1, '// Date:9 April,2012'), + (2, '// Author:Frankie.Chu'), + ] + expected = [ + copyrights.AuthorDetection('Frankie.Chu', 2, 2), + ] + results = list(copyrights.detect_copyrights_from_lines( + numbered_lines, + include_copyrights=False, + include_holders=False, + include_authors=True, + )) + assert results == expected + def check_full_detections(expected, test_file): """ From d2b3270c57a4028ce6c6542ca991a8ee60c53a5d Mon Sep 17 00:00:00 2001 From: Hrithik Sharma Date: Fri, 11 Sep 2026 16:39:11 +0530 Subject: [PATCH 2/2] Scope dotted author name handling to author tags Signed-off-by: Hrithik Sharma --- src/cluecode/copyrights.py | 10 +++++++--- tests/cluecode/test_copyrights_basic.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cluecode/copyrights.py b/src/cluecode/copyrights.py index 155a349dbcf..e3f1b3c2e33 100644 --- a/src/cluecode/copyrights.py +++ b/src/cluecode/copyrights.py @@ -440,6 +440,13 @@ def get_tokens(numbered_lines, splitter=re.compile(r'[\t =;]+').split): string=line, ) + # Normalize dotted names only when they follow an Author tag. + line = re.sub( + pattern=r'(^|\s)([Aa]uthor)\s+([A-Z][a-z]+)\.([A-Z][a-z]+)(?=\b|[,;])', + repl=r'\1\2 \3 \4', + string=line, + ) + for tok in splitter(line): # strip trailing quotes+comma if tok.endswith("',"): @@ -1814,9 +1821,6 @@ def build_detection_from_node( # Proper Nouns ############################################################################ - # Dotted proper names such as Frankie.Chu - (r'^[A-Z][a-z]+(?:\.[A-Z][a-z]+)+$', 'NAME'), - # Title case word with a trailing parens is an NNP, including with an optional trailing period (r'^[A-Z][a-z]{3,}\)\.?$', 'NNP'), # Title case word with a leading parens is an NNP diff --git a/tests/cluecode/test_copyrights_basic.py b/tests/cluecode/test_copyrights_basic.py index 2741dbf95d1..b6f6790d5da 100644 --- a/tests/cluecode/test_copyrights_basic.py +++ b/tests/cluecode/test_copyrights_basic.py @@ -325,7 +325,7 @@ def test_detect_author_without_space_and_with_dotted_name(self): (2, '// Author:Frankie.Chu'), ] expected = [ - copyrights.AuthorDetection('Frankie.Chu', 2, 2), + copyrights.AuthorDetection('Frankie Chu', 2, 2), ] results = list(copyrights.detect_copyrights_from_lines( numbered_lines,