Example #1
0
    def test_copyrights(self):
        text = '(C)Maverick(R) International Processing Services, Inc. 1999'
        cs = list(get_copyright(text))
        self.assertEqual(1, len(cs))

        ant = list(get_copyright_annotations(text))[0]
        self.assertEqual((0, 61), ant.coords)
        cite = ant.get_cite()
        self.assertEqual('/en/copyright/Maverick/1999', cite)
Example #2
0
 def test_big_file(self):
     file_path = os.path.join(lexnlp_test_path,
                              'lexnlp/extract/en/copyrights/bigfile.txt')
     with codecs.open(file_path, encoding='utf-8', mode='r') as of:
         text = of.read()
     cs = []
     for part in text.split('\n\n'):
         for ant in get_copyright_annotations(part):
             cs.append(ant)
     self.assertEqual(3, len(cs))
Example #3
0
    def test_text_coords(self):
        text = """
The provisions contained in Sections 2   through 36, inclusive, which 
appear after the signature lines below, are a part of this Lease and are 
incorporated in this Lease by reference. The (C)Tenant(R) and the Landlord have 
executed or caused to be executed this Lease on the dates shown below their 
signatures, to be effective as of the date set forth above.
        """
        ant = list(get_copyright_annotations(text))[0]
        start = text.find('(C)Tenant')
        self.assertEqual(start, ant.coords[0])
Example #4
0
 def parse(self, log: ProcessLogger, text, text_unit_id, _text_unit_lang, **kwargs) -> ParseResults:
     # TODO: what's the logic behind [:200] ... < 100 ?
     found = list(copyright.get_copyright_annotations(text, return_sources=True))
     if found:
         unique = set(found)
         return ParseResults({CopyrightUsage: [CopyrightUsage(text_unit_id=text_unit_id,
                                                              year=item.date,
                                                              name=item.name[:200],
                                                              copyright_str=item.text[:200],
                                                              count=found.count(item)
                                                              ) for item in unique if len(item.name) < 100]})
Example #5
0
def get_copyright_verbose_annotations(text: str) -> \
        Generator[CopyrightAnnotation, None, None]:
    yield from get_copyright_annotations(text, return_sources=True)