コード例 #1
0
ファイル: test_data.py プロジェクト: stanfordnlp/stanza
 def test_parse_pb(self, document_pb):
     document = AnnotatedDocument.from_pb(document_pb)
     assert (
         document.text
         == u"Barack Hussein Obama is an American politician who is the 44th and current President of the United States. He is the first African American to hold the office and the first president born outside the continental United States. Born in Honolulu, Hawaii, Obama is a graduate of Columbia University and Harvard Law School, where he was president of the Harvard Law Review."
     )
     assert len(document) == 3
     assert document[0][1].word == "Hussein"
     assert document[0][1].ner == "PERSON"
コード例 #2
0
ファイル: tests.py プロジェクト: arunchaganty/django-corenlp
    def setUpClass(cls, *args):
        with open(os.path.join(TEST_DATA, "doc.txt"), "r") as f:
            doc_txt = f.read()
        with open(os.path.join(TEST_DATA, "doc.pb"), "rb") as f:
            pb = proto.Document()
            pb.ParseFromString(f.read())
            ann = AnnotatedDocument.from_pb(pb)

        cls._doc = Document(id="test",
                            corpus_id="test",
                            created=datetime.now(),
                            date=datetime.now(),
                            title="test",
                            gloss=doc_txt,
                            metadata="")
        cls._doc.save()
        cls._ann = ann
        cls._client = MockCoreNLPClient(cls._doc, cls._ann)
        super(CoreNLPTestCase, cls).setUpClass(*args)
コード例 #3
0
 def test_mentions(self, document_pb):
     document = AnnotatedDocument.from_pb(document_pb)
     mentions = document.mentions
     assert len(mentions) == 17
コード例 #4
0
 def test_parse_pb(self, document_pb):
     document = AnnotatedDocument.from_pb(document_pb)
     assert document.text == u"Barack Hussein Obama is an American politician who is the 44th and current President of the United States. He is the first African American to hold the office and the first president born outside the continental United States. Born in Honolulu, Hawaii, Obama is a graduate of Columbia University and Harvard Law School, where he was president of the Harvard Law Review."
     assert len(document) == 3
     assert document[0][1].word == "Hussein"
     assert document[0][1].ner == "PERSON"
コード例 #5
0
ファイル: test_data.py プロジェクト: futurulus/rl-cards
 def test_mentions(self, document_pb):
     document = AnnotatedDocument.from_pb(document_pb)
     mentions = document.mentions
     assert len(mentions) == 17