use of com.graphaware.nlp.util.TestAnnotatedText in project neo4j-nlp-stanfordnlp by graphaware.
the class TextProcessorTest method testAnnotatedText.
@Test
public void testAnnotatedText() {
AnnotatedText annotatedText = textProcessor.annotateText("On 8 May 2013, " + "one week before the Pakistani election, the third author, " + "in his keynote address at the Sentiment Analysis Symposium, " + "forecast the winner of the Pakistani election. The chart " + "in Figure 1 shows varying sentiment on the candidates for " + "prime minister of Pakistan in that election. The next day, " + "the BBC’s Owen Bennett Jones, reporting from Islamabad, wrote " + "an article titled “Pakistan Elections: Five Reasons Why the " + "Vote is Unpredictable,”1 in which he claimed that the election " + "was too close to call. It was not, and despite his being in Pakistan, " + "the outcome of the election was exactly as we predicted.", "en", PIPELINE_DEFAULT);
TestAnnotatedText test = new TestAnnotatedText(annotatedText);
test.assertSentencesCount(4);
test.assertTagsCountInSentence(15, 0);
test.assertTagsCountInSentence(11, 1);
test.assertTagsCountInSentence(24, 2);
test.assertTagsCountInSentence(8, 3);
test.assertTag(newTag("Pakistan", Collections.singletonList("LOCATION"), Collections.emptyList()));
test.assertTag(newTag("show", Collections.emptyList(), Collections.singletonList("VBZ")));
}
use of com.graphaware.nlp.util.TestAnnotatedText in project neo4j-nlp by graphaware.
the class TestAnnotatedTesterUnitTest method testSentencesCountIsCorrect.
@Test
public void testSentencesCountIsCorrect() {
AnnotatedText annotatedText = new AnnotatedText();
TestAnnotatedText test = new TestAnnotatedText(annotatedText);
Sentence sentence = new Sentence("hello");
sentence.addTag(new Tag("hello", "en"));
annotatedText.addSentence(sentence);
test.assertSentencesCount(1);
}
use of com.graphaware.nlp.util.TestAnnotatedText in project neo4j-nlp by graphaware.
the class TestAnnotatedTesterUnitTest method testSentenceCountThrowsExceptionWhenNotCorrect.
@Test(expected = AssertionError.class)
public void testSentenceCountThrowsExceptionWhenNotCorrect() {
AnnotatedText annotatedText = new AnnotatedText();
TestAnnotatedText tester = new TestAnnotatedText(annotatedText);
tester.assertSentencesCount(1);
}
use of com.graphaware.nlp.util.TestAnnotatedText in project neo4j-nlp by graphaware.
the class TestAnnotatedTesterUnitTest method assertTagEquals.
@Test
public void assertTagEquals() {
AnnotatedText annotatedText = new AnnotatedText();
TestAnnotatedText test = new TestAnnotatedText(annotatedText);
Sentence sentence = new Sentence("John is working in Denver for IBM");
sentence.addTag(newTag("John", singletonList("PERSON"), emptyList()));
sentence.addTag(newTag("Denver", singletonList("LOCATION"), emptyList()));
sentence.addTag(newTag("IBM", singletonList("ORGANIZATION"), emptyList()));
sentence.addTag(newTag("work"));
annotatedText.addSentence(sentence);
test.assertTag(newTag("John", singletonList("PERSON"), emptyList()));
test.assertTag(newTag("IBM", singletonList("ORGANIZATION"), emptyList()));
test.assertTag(newTag("work"));
}
use of com.graphaware.nlp.util.TestAnnotatedText in project neo4j-nlp by graphaware.
the class TestAnnotatedTesterUnitTest method testTagIsNotFound.
@Test(expected = AssertionError.class)
public void testTagIsNotFound() {
AnnotatedText annotatedText = new AnnotatedText();
TestAnnotatedText test = new TestAnnotatedText(annotatedText);
Sentence sentence = new Sentence("hello it is me");
sentence.addTag(new Tag("hello", "en"));
annotatedText.addSentence(sentence);
test.assertTagWithLemma("hella");
}
Aggregations