@@ -61,7 +61,6 @@ def logger_debug(*args):
6161if TRACE_DEEP :
6262 logger_debug = print
6363
64-
6564"""
6665Detect and collect copyright statements.
6766
@@ -428,6 +427,10 @@ def get_tokens(numbered_lines, splitter=re.compile(r'[\t =;]+').split):
428427 if TRACE_TOK :
429428 logger_debug (' get_tokens: preped line: ' + repr (line ))
430429
430+ # when there is a an openning parens in the middle of a word, add a
431+ # space before in some cases: exclude (digit , (s , (c , (-
432+ # this allows to recover from words like KISA(Korean
433+ line = re .sub (pattern = r'(\([^rsc\-\d])' , repl = r' \g<1>' , string = line )
431434 for tok in splitter (line ):
432435 # strip trailing quotes+comma
433436 if tok .endswith ("'," ):
@@ -729,6 +732,10 @@ def build_detection_from_node(
729732 # SPDX-FileContributor as defined in SPDX and seen used in KDE
730733 (r'^[Ss][Pp][Dd][Xx]-[Ff]ile[Cc]ontributor' , 'SPDX-CONTRIB' ),
731734
735+ # damaged PDF to text conversion with (cid:13) and rarer (cid:2)
736+ (r'^[Cc]?\(cid:13\)$' , 'COPY' ),
737+ (r'^[Cc]?\(cid:2\)$' , 'COPY' ),
738+
732739 ############################################################################
733740 # ALL Rights Reserved.
734741 ############################################################################
@@ -814,6 +821,9 @@ def build_detection_from_node(
814821 (r'^W3C\(r\)$' , 'COMP' ),
815822 (r'^TeX$' , 'NNP' ),
816823
824+ # Copyright (c) 1989 ITAA, formerly ADAPSO
825+ (r'^formerly' , 'NNP' ),
826+
817827 # Three or more AsCamelCase GetQueueReference, with some exceptions
818828 (r'^(?:OpenStreetMap|AliasDotCom|AllThingsTalk).?$' , 'NAME' ),
819829
@@ -991,6 +1001,9 @@ def build_detection_from_node(
9911001 (r'^.?(null|function|try|catch|except|throw|typeof|catch|switch).?$' , 'JUNK' ),
9921002 (r'^.*[\.:](?:value|ref|key|case|type|typeof|props|state|error|null)$' , 'JUNK' ),
9931003 (r'^[a-z]{,5}\[!?]+' , 'JUNK' ),
1004+ (r'^(fprintf|stderr)$' , 'JUNK' ),
1005+
1006+ (r'^[Aa]uthor\(s\)\.?$' , 'AUTHDOT' ),
9941007
9951008 # func call with short var in minified code
9961009 (r'^\w{2,6}\([a-z, ]{1,6}\)' , 'JUNK' ),
@@ -1226,17 +1239,21 @@ def build_detection_from_node(
12261239 (r'^param$' , 'JUNK' ),
12271240 (r'^which$' , 'JUNK' ),
12281241
1242+ # github/gitlab usernames
1243+ (r'^Hiroki11x$' , 'NNP' ),
1244+ (r'^goldze$' , 'NNP' ),
1245+
12291246 # "Es6ToEs3ClassSideInheritance. and related names
12301247 (r"^[A-Z]([a-zA-Z]*[0-9]){2,}[a-zA-Z]+[\.,]?" , 'JUNK' ),
12311248
12321249 # owlocationNameEntitieship.
12331250 (r"^([a-z]{2,}[A-Z]){2,}[a-z]+[\.,]?" , 'JUNK' ),
12341251
1252+ # lower case with (s)
1253+ # but not owner/author(s).
1254+ (r"^owner/author\(s\)\.?$" , 'NNP' ),
12351255 (r"^[a-z].+\(s\)[\.,]?$" , 'JUNK' ),
12361256
1237- # parens in the middle: for(var
1238- (r"^[a-zA-Z]+[\)\(]+,?[\)\(]?[a-zA-Z]+[\.,]?$" , 'JUNK' ),
1239-
12401257 # single period
12411258 (r"^\.$" , 'JUNK' ),
12421259
@@ -1284,6 +1301,12 @@ def build_detection_from_node(
12841301 (r'^[Bb]oth$' , 'JUNK' ),
12851302 (r'^[Cc]aller$' , 'JUNK' ),
12861303
1304+ # '!(r)'
1305+ (r'^!\(r\)$' , 'JUNK' ),
1306+
1307+ # vars with parens
1308+ (r'\(var' , 'JUNK' ),
1309+
12871310 # tags
12881311 (r'^E-?[Mm]ail:?$' , 'JUNK' ),
12891312 (r'^URL:?$' , 'JUNK' ),
@@ -1876,7 +1899,7 @@ def build_detection_from_node(
18761899
18771900 # rare form of trailing punct in name: Ian Robertson).
18781901 (r'^Robert.*' , 'NNP' ),
1879-
1902+
18801903 ############################################################################
18811904 # Named entities: companies, groups, universities, etc
18821905 ############################################################################
@@ -2023,9 +2046,9 @@ def build_detection_from_node(
20232046 (r'^[Aa]uthor$' , 'AUTH' ),
20242047 (r'^[Aa]uthor\.$' , 'AUTHDOT' ),
20252048 (r'^[Aa]uthors?\.$' , 'AUTHDOT' ),
2049+ (r'^[Aa]uthor\(s\)\.?$' , 'AUTHDOT' ),
20262050 (r'^([Aa]uthors|author\')$' , 'AUTHS' ),
20272051 (r'^[Aa]uthor\(s\)$' , 'AUTHS' ),
2028- (r'^[Aa]uthor\(s\)\.?$' , 'AUTHDOT' ),
20292052 # as javadoc
20302053 (r'^@[Aa]uthors?:?$' , 'AUTH' ),
20312054
@@ -2195,6 +2218,12 @@ def build_detection_from_node(
21952218 # all other cardinal numbers
21962219 (r'^-?[0-9]+(.[0-9]+)?[\.,]?$' , 'CD' ),
21972220
2221+ # onwards used in year ranges
2222+ (r'^onwards,?$' , 'ONWARDS' ),
2223+ # beyond is the same
2224+ (r'^beyond,?$' , 'ONWARDS' ),
2225+
2226+
21982227 ############################################################################
21992228 # All caps and proper nouns
22002229 ############################################################################
@@ -2214,6 +2243,7 @@ def build_detection_from_node(
22142243 (r'^Xiph.Org$' , 'NNP' ),
22152244 (r'^iClick,?$' , 'NNP' ),
22162245 (r'^electronics?$' , 'NNP' ),
2246+ (r'^semiconductors?[\.,]?$' , 'NNP' ),
22172247
22182248 # proper nouns with digits
22192249 (r'^([A-Z][a-z0-9]+){1,2}[\.,]?$' , 'NNP' ),
@@ -2234,6 +2264,7 @@ def build_detection_from_node(
22342264 (r"^[a-z]'[A-Z]?[a-z]+[,\.]?$" , 'NNP' ),
22352265
22362266 # exceptions to all CAPS words
2267+ (r'^ISBN$' , 'NN' ),
22372268 (r'^[A-Z]{3,4}[0-9]{4},?$' , 'NN' ),
22382269
22392270 # exceptions to CAPS used in obfuscated emails like in joe AT foo DOT com
@@ -2350,8 +2381,6 @@ def build_detection_from_node(
23502381 # some punctuation combos
23512382 (r'^(?:=>|->|<-|<=)$' , 'JUNK' ),
23522383
2353- (r'^semiconductors?[\.,]?$' , 'NNP' ),
2354-
23552384 ############################################################################
23562385 # catch all other as Nouns
23572386 ############################################################################
@@ -2385,6 +2414,9 @@ def build_detection_from_node(
23852414
23862415 # 5 Jan 2003
23872416 YR-RANGE: {<CDS> <NNP> <YR-RANGE>} #72.3
2417+
2418+ # 2024 and? onwards
2419+ YR-RANGE: {<YR-RANGE><CC>?<ONWARDS>}
23882420
23892421
23902422#######################################
@@ -2924,7 +2956,8 @@ def build_detection_from_node(
29242956 # Copyright 2015 The Happy Campers
29252957 # Copyright 2015 The Error Prone Authors.
29262958 # Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic,
2927- COPYRIGHT: {<NNP>? <COPY>+ (<YR-RANGE>+ <BY>? <NN>? <COMPANY|NAME|NAME-EMAIL|NNP>+ <EMAIL>?)+ <AUTHDOT|MAINT>?} #1630
2959+ # AssemblyCopyright("(c) 2004 by Henrik Ravn")]
2960+ COPYRIGHT: {<NNP>? <COPY>+ <PARENS>? <COPY>? (<YR-RANGE>+ <BY>? <NN>? <COMPANY|NAME|NAME-EMAIL|NNP>+ <EMAIL>?)+ <AUTHDOT|MAINT>?} #1630
29282961
29292962 COPYRIGHT: {<COPY>+ <NN> <NAME> <YR-RANGE>} #1650
29302963
@@ -3046,6 +3079,9 @@ def build_detection_from_node(
30463079 # Copyright base-x contributors (c) 2016
30473080 COPYRIGHT: {<COPY>+ <NN> <CONTRIBUTORS|COMMIT|AUTHS|MAINT> <COPY> <YR-RANGE>} #22793.2
30483081
3082+ # Copyright © 2021 Ha and Maguire.
3083+ COPYRIGHT: {<COPY>+ <YR-RANGE> <NN> <CC> <NNP>} #22793.31
3084+
30493085 # Copyright (c) 2017 odahcam
30503086 # Copyright (C) 2006 XStream committers.
30513087 # Copyright (c) 2019-2021, Open source contributors.
@@ -3076,8 +3112,16 @@ def build_detection_from_node(
30763112 # Author: Jeff LaBundy <jeff@labundy.com>
30773113 COPYRIGHT: {<COPY> <COPY> <YR-RANGE> <AUTH> <NAME-EMAIL>} #2280-3
30783114
3115+ # Common for ACM notices
3116+ # Copyright is held by the owner/author(s).
3117+ # (c) 2016 Copyright held by the owner/author(s).
3118+ COPYRIGHT2: {<COPY>+ <YR-RANGE>+ <COPY><IS>?<HELD><BY><NN>?<NNP>} #2280-9
30793119
30803120 COPYRIGHT2: {<COPY>+ <NN|CAPS>? <YR-RANGE>+ <PN>*} #2280
3121+ COPYRIGHT2: {<COPY><IS>?<HELD><BY><NN>?<NNP>} #2280-12
3122+
3123+ # Copyright (c) 1995-2012 held by the author(s). All rights reserved.'
3124+ COPYRIGHT: {<COPYRIGHT2><HELD><BY><NN><AUTHDOT>} #2280-40
30813125
30823126 COPYRIGHT: {<COPYRIGHT2> <BY> <NAME-YEAR|NAME-EMAIL> <BY>? <NAME-YEAR|NAME-EMAIL>? } #2280-4
30833127
@@ -3107,7 +3151,8 @@ def build_detection_from_node(
31073151 # Rare form Copyright (c) 2008 All rights reserved by Amalasoft Corporation.
31083152 COPYRIGHT: {<COPYRIGHT2> <ALLRIGHTRESERVED> <BY> <COMPANY>} #2861
31093153
3110- # Copyright (c) 1996 Adrian Rodriguez (adrian@franklins-tower.rutgers.edu) Laboratory for Computer Science Research Computing Facility
3154+ # Copyright (c) 1996 Adrian Rodriguez (adrian@franklins-tower.rutgers.edu) L
3155+ # aboratory for Computer Science Research Computing Facility
31113156 COPYRIGHT: {<COPYRIGHT> <NAME>} #2400
31123157
31133158 # copyrights in the style of Scilab/INRIA
@@ -3288,7 +3333,12 @@ def build_detection_from_node(
32883333 COPYRIGHT: {<COPY> <COPY> <ANDCO>} #2841
32893334
32903335 # Copyright (c) 1995-2018 The PNG Reference Library Authors. (with and without trailing dot)
3291- COPYRIGHT: {<COPYRIGHT> <NN> <AUTHDOT>} #35011
3336+ # Copyright 2001 - 2009 by the original author(s).
3337+ # Copyright 2021 The logr Authors.
3338+ # Copyright 2022 The JSpecify Authors.
3339+ # attach a trailing "Authors." even when the preceding name was already
3340+ # absorbed into the COPYRIGHT node (e.g. names tagged NN like "logr", "JSpecify")
3341+ COPYRIGHT: {<COPYRIGHT|COPYRIGHT2> <NN>{0,2} <AUTHDOT>} #35011
32923342
32933343 ############ All right reserved in the middle ##############################
32943344
@@ -3406,6 +3456,11 @@ def build_detection_from_node(
34063456 NAME-EMAIL: {<DASH> <NAME-EMAIL> <NN>?} #157999.14
34073457 COPYRIGHT: {<COPYRIGHT2> <FOLLOWING> <AUTHS> <NAME-EMAIL>+ } #157999.14
34083458
3459+ # Copyright (C) 2011-2012 The OpenTSDB Authors.
3460+ COPYRIGHT: {<COPYRIGHT> <AUTHDOT>} #160000
3461+
3462+ # (c) The Author(s).
3463+ COPYRIGHT: {<COPY> <NN> <AUTHS>}
34093464
34103465#######################################
34113466# Copyright is held by ....
@@ -4013,6 +4068,7 @@ def remove_dupe_copyright_words(c):
40134068 c = c .replace ("copyright\' " , 'Copyright' )
40144069 c = c .replace ('and later' , ' ' )
40154070 c = c .replace ('build.year' , ' ' )
4071+
40164072 return c
40174073
40184074
@@ -4545,6 +4601,10 @@ def prepare_text_line(line):
45454601 .replace ('\xc2 ' , '' )
45464602 .replace ('\\ xc2' , '' )
45474603
4604+ # PDF to text damages
4605+ .replace ('c(cid:13)' , '(c) ' )
4606+ .replace ('c(cid:2)' , '(c) ' )
4607+
45484608 # not really a dash: an emdash
45494609 .replace ('–' , '-' )
45504610
0 commit comments