Skip to content

Commit 50eaeec

Browse files
authored
Merge pull request #352 from nexB/351-copyright-bv
#351 Support collecting BV company suffix in copyrights
2 parents 2760f40 + 3840d3d commit 50eaeec

3 files changed

Lines changed: 25 additions & 13 deletions

File tree

src/cluecode/copyrights.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2015 nexB Inc. and others. All rights reserved.
2+
# Copyright (c) 2016 nexB Inc. and others. All rights reserved.
33
# http://nexb.com and https://github.com/nexB/scancode-toolkit/
44
# The ScanCode software is licensed under the Apache License version 2.0.
55
# Data generated with ScanCode require an acknowledgment.
@@ -158,6 +158,8 @@ def detect(location):
158158
(r'^[Gg][Mm][Bb][Hh].?$', 'COMP'),
159159
# (italian) company suffix
160160
(r'^[sS]\.[pP]\.[aA]\.?$', 'COMP'),
161+
# (dutch and belgian) company suffix
162+
(r'^[Bb]\.?[Vv]\.?|BVBA$', 'COMP'),
161163
# university
162164
(r'^[Uu]niv([.]|ersit(y|e|at?|ad?))$', 'UNI'),
163165
# institutes
@@ -693,7 +695,7 @@ def detect(self, numbered_lines):
693695
numbers = [n for n, _l in numbered_lines]
694696
start_line = min(numbers)
695697
end_line = max(numbers)
696-
#logger.debug('CopyrightDetector:detect:lines numbers: %(start_line)d->%(end_line)d' % locals())
698+
# logger.debug('CopyrightDetector:detect:lines numbers: %(start_line)d->%(end_line)d' % locals())
697699
tokens = self.get_tokens(numbered_lines)
698700

699701
# we accumulate detected items in these synchronized lists
@@ -712,11 +714,11 @@ def detect(self, numbered_lines):
712714

713715
# first, POS tag each token using token regexes
714716
tagged_text = self.tagger.tag(tokens)
715-
#logger.debug('CopyrightDetector:tagged_text: ' + str(tagged_text))
717+
# logger.debug('CopyrightDetector:tagged_text: ' + str(tagged_text))
716718

717719
# then build a parse tree based on tagged tokens
718720
tree = self.chunker.parse(tagged_text)
719-
#logger.debug('CopyrightDetector:parse tree: ' + str(tree))
721+
# logger.debug('CopyrightDetector:parse tree: ' + str(tree))
720722

721723
# OPTIMIZED
722724
nltk_tree_Tree = nltk.tree.Tree
@@ -729,7 +731,7 @@ def collect_year_and_holder(detected_copyright):
729731
"""
730732
for copyr in detected_copyright:
731733
if isinstance(copyr, nltk_tree_Tree):
732-
#logger.debug('n: ' + str(copyr))
734+
# logger.debug('n: ' + str(copyr))
733735
node_text = CopyrightDetector_as_str(copyr)
734736
copyr_label = copyr.label()
735737
if 'YR-RANGE' in copyr_label:
@@ -738,7 +740,7 @@ def collect_year_and_holder(detected_copyright):
738740
# FIXME : this would wreck things like 23andme
739741
# where a company name contains numbers
740742
holders_append(refine_author(node_text))
741-
#logger.debug('CopyrightDetector: node_text: ' + node_text)
743+
# logger.debug('CopyrightDetector: node_text: ' + node_text)
742744
collect_year_and_holder(copyr)
743745

744746
# then walk the parse tree, collecting copyrights, years and authors
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*
2+
* Copyright (c) 2016 HERE Europe B.V. All rights Reserved.
3+
4+
© HERE 2016
5+
*/

tests/cluecode/test_copyrights.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright (c) 2015 nexB Inc. and others. All rights reserved.
3+
# Copyright (c) 2016 nexB Inc. and others. All rights reserved.
44
# http://nexb.com and https://github.com/nexB/scancode-toolkit/
55
# The ScanCode software is licensed under the Apache License version 2.0.
66
# Data generated with ScanCode require an acknowledgment.
@@ -3085,8 +3085,8 @@ def test_copyright_openoffice_org_report_builder_bin_copyright(self):
30853085
u'Copyright (c) 1991-1998, Thomas G. Lane',
30863086
u'Copyright 1994-2002 World Wide Web Consortium',
30873087
u'Copyright (c) 2002 Anders Carlsson <andersca@gnu.org>',
3088-
u'Copyright (c) 2003, WiseGuys Internet',
3089-
u'Copyright (c) 2003, WiseGuys Internet',
3088+
u'Copyright (c) 2003, WiseGuys Internet B.V.',
3089+
u'Copyright (c) 2003, WiseGuys Internet B.V.',
30903090
u'Copyright 1997-1999 World Wide Web Consortium',
30913091
u'Copyright (c) 2002-2003 Aleksey Sanin',
30923092
u'Copyright (c) 2003 America Online, Inc.',
@@ -3928,14 +3928,14 @@ def test_copyright_should_not_have_trailing_available(self):
39283928

39293929
@expectedFailure
39303930
def test_copyright_with_dots_and_all_lowercase_on_multilines(self):
3931-
test_lines = [u'Copyright . 2008 company name, inc.',
3932-
u' Change: Add functions',]
3931+
test_lines = [u'Copyright . 2008 company name, inc.',
3932+
u' Change: Add functions', ]
39333933
expected = [u'Copyright . 2008 company name, inc.']
39343934
check_detection(expected, test_lines)
39353935

39363936
def test_copyright_with_dots_and_all_lowercase_on_multilines_current(self):
3937-
test_lines = [u'Copyright . 2008 company name, inc.',
3938-
u' Change: Add functions',]
3937+
test_lines = [u'Copyright . 2008 company name, inc.',
3938+
u' Change: Add functions', ]
39393939
expected = [u'Copyright . 2008']
39403940
check_detection(expected, test_lines)
39413941

@@ -3966,3 +3966,8 @@ def test_copyright_should_not_detected_in_apache_html(self):
39663966
test_file = self.get_test_loc('copyrights/copyright_apache_in_html.html')
39673967
expected = []
39683968
check_detection(expected, test_file)
3969+
3970+
def test_copyright_bv_legal_entity(self):
3971+
test_file = self.get_test_loc('copyrights/bv.txt')
3972+
expected = [u'Copyright (c) 2016 HERE Europe B.V.', u'(c) HERE 2016']
3973+
check_detection(expected, test_file)

0 commit comments

Comments
 (0)