diff --git a/AUTHORS.rst b/AUTHORS.rst index 9a8224dc7d..9f92147e84 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -61,6 +61,7 @@ The following organizations or individuals have contributed to ScanCode: - Nisha Kumar @nishakm - Nishchith Shetty @inishchith - Nitish Sharma @nitish81299 +- Wonjae Park @JustinWonjaePark - Paul Gier @pgier - Philippe Ombredanne @pombredanne - Pi Delport @PiDelport diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d9a5a6b402..02533e189a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,8 @@ Changelog Next release -------------- +- Improve copyright holder detection for lower camel case names. + - Fix the optional ``licenses`` extra dependency typo to install ``licensedcode-data``. https://github.com/aboutcode-org/scancode-toolkit/pull/5056 diff --git a/src/cluecode/copyrights.py b/src/cluecode/copyrights.py index 6d17467acf..f4209213a4 100644 --- a/src/cluecode/copyrights.py +++ b/src/cluecode/copyrights.py @@ -286,6 +286,17 @@ def detect(self, # first, POS tag each token using token regexes lexed_text = list(self.lexer.lex_tokens(tokens, trace=TRACE_TOK)) + + for index, token in enumerate(lexed_text): + if ( + index + and token.label == 'JUNK' + and lexed_text[index - 1].label == 'YR' + and token.start_line == lexed_text[index - 1].start_line + and re.match(r'^[a-z]{2,}[A-Z][a-z]+(?:[A-Z][a-z]+)*[\.,]?$', token.value) + ): + token.label = 'MIXEDCAP' + if TRACE or TRACE_DEEP: logger_debug(f'CopyrightDetector: lexed tokens:') for l in lexed_text: diff --git a/tests/cluecode/data/copyrights/lower_camel_case_holder.txt b/tests/cluecode/data/copyrights/lower_camel_case_holder.txt new file mode 100644 index 0000000000..e78bdb9c0d --- /dev/null +++ b/tests/cluecode/data/copyrights/lower_camel_case_holder.txt @@ -0,0 +1,2 @@ +Copyright (c) 2021, drGlennPierce +Copyright (c) 2022, myCompany diff --git a/tests/cluecode/data/copyrights/lower_camel_case_holder.txt.yml b/tests/cluecode/data/copyrights/lower_camel_case_holder.txt.yml new file mode 100644 index 0000000000..77e2a4baef --- /dev/null +++ b/tests/cluecode/data/copyrights/lower_camel_case_holder.txt.yml @@ -0,0 +1,9 @@ +what: + - copyrights + - holders +copyrights: + - Copyright (c) 2021, drGlennPierce + - Copyright (c) 2022, myCompany +holders: + - drGlennPierce + - myCompany