File size: 797 Bytes
8b513d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24a93ab
 
8b513d0
 
24a93ab
8b513d0
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import unittest
import spacy
from spacyEntityLinker.EntityLinker import EntityLinker


class TestEntityLinker(unittest.TestCase):

    def __init__(self, arg, *args, **kwargs):
        super(TestEntityLinker, self).__init__(arg, *args, **kwargs)
        self.nlp = spacy.load('en_core_web_sm')

    def test_initialization(self):
        entityLinker = EntityLinker()

        self.nlp.add_pipe(entityLinker, last=True, name="entityLinker")

        doc = self.nlp(
            "Elon Musk was born in South Africa. Bill Gates and Steve Jobs come from in the United States")

        doc._.linkedEntities.pretty_print()
        doc._.linkedEntities.print_super_entities()
        for sent in doc.sents:
            sent._.linkedEntities.pretty_print()

        self.nlp.remove_pipe("entityLinker")