Skip to content

Commit d2b3270

Browse files
committed
Scope dotted author name handling to author tags
Signed-off-by: Hrithik Sharma <sharmahrithik2806@gmail.com>
1 parent 1ebd0dc commit d2b3270

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/cluecode/copyrights.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,13 @@ def get_tokens(numbered_lines, splitter=re.compile(r'[\t =;]+').split):
440440
string=line,
441441
)
442442

443+
# Normalize dotted names only when they follow an Author tag.
444+
line = re.sub(
445+
pattern=r'(^|\s)([Aa]uthor)\s+([A-Z][a-z]+)\.([A-Z][a-z]+)(?=\b|[,;])',
446+
repl=r'\1\2 \3 \4',
447+
string=line,
448+
)
449+
443450
for tok in splitter(line):
444451
# strip trailing quotes+comma
445452
if tok.endswith("',"):
@@ -1814,9 +1821,6 @@ def build_detection_from_node(
18141821
# Proper Nouns
18151822
############################################################################
18161823

1817-
# Dotted proper names such as Frankie.Chu
1818-
(r'^[A-Z][a-z]+(?:\.[A-Z][a-z]+)+$', 'NAME'),
1819-
18201824
# Title case word with a trailing parens is an NNP, including with an optional trailing period
18211825
(r'^[A-Z][a-z]{3,}\)\.?$', 'NNP'),
18221826
# Title case word with a leading parens is an NNP

tests/cluecode/test_copyrights_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def test_detect_author_without_space_and_with_dotted_name(self):
325325
(2, '// Author:Frankie.Chu'),
326326
]
327327
expected = [
328-
copyrights.AuthorDetection('Frankie.Chu', 2, 2),
328+
copyrights.AuthorDetection('Frankie Chu', 2, 2),
329329
]
330330
results = list(copyrights.detect_copyrights_from_lines(
331331
numbered_lines,

0 commit comments

Comments
 (0)