|
@@ 142-152 (lines=11) @@
|
| 139 |
|
rules_url = "https://raw.githubusercontent.com/clulab/reach/master/src/main/resources/edu/arizona/sista/demo/open/grammars/rules.yml" |
| 140 |
|
text = 'Inigo Montoya should be flagged as a Person.' |
| 141 |
|
mentions = API.odin.extract_from_text(text, rules_url) |
| 142 |
|
self.assertTrue(len(mentions) != 0, "No mentions were found") |
| 143 |
|
m = mentions[0] |
| 144 |
|
self.assertIsInstance(m, Mention, "m wasn't a Mention") |
| 145 |
|
person_mentions = [m for m in mentions if m.label == "Person"] |
| 146 |
|
self.assertTrue(len(person_mentions) == 1, "{} \"Person\" Mentions found, but 1 expected.".format(len(person_mentions))) |
| 147 |
|
|
| 148 |
|
def test_odin_extract_from_document_method(self): |
| 149 |
|
"API.odin.extract_from_document should return mentions whenever rules match the text" |
| 150 |
|
rules = """ |
| 151 |
|
- name: "ner-person" |
| 152 |
|
label: [Person, PossiblePerson, Entity] |
| 153 |
|
priority: 1 |
| 154 |
|
type: token |
| 155 |
|
pattern: | |
|
@@ 111-120 (lines=10) @@
|
| 108 |
|
# test with Document |
| 109 |
|
doc = API.annotate(text) |
| 110 |
|
scores = API.sentiment.corenlp.score(doc) |
| 111 |
|
self.assertTrue(len(scores) > 0, "there were no sentiment scores returned for the Document") |
| 112 |
|
# test with Sentence |
| 113 |
|
s = doc.sentences[0] |
| 114 |
|
score = API.sentiment.corenlp.score(s) |
| 115 |
|
self.assertIsInstance(score, int, "score for Sentence should be of type int, but was of type {}".format(type(score))) |
| 116 |
|
|
| 117 |
|
# Odin tests |
| 118 |
|
def test_odin_extract_from_text_method(self): |
| 119 |
|
"API.odin.extract_from_text should return mentions whenever rules match the text" |
| 120 |
|
rules = """ |
| 121 |
|
- name: "ner-person" |
| 122 |
|
label: [Person, PossiblePerson, Entity] |
| 123 |
|
priority: 1 |