use of com.graphaware.nlp.util.TestAnnotatedText in project neo4j-nlp by graphaware.
the class TestAnnotatedTesterUnitTest method assertTagNotEquals.
@Test(expected = AssertionError.class)
public void assertTagNotEquals() {
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"));
}
use of com.graphaware.nlp.util.TestAnnotatedText in project neo4j-nlp by graphaware.
the class TestAnnotatedTesterUnitTest method testTagIsFound.
@Test
public void testTagIsFound() {
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);
test.assertTagWithLemma("hello");
}
use of com.graphaware.nlp.util.TestAnnotatedText in project neo4j-nlp by graphaware.
the class TestAnnotatedTesterUnitTest method testSentenceWithNoText.
@Test(expected = AssertionError.class)
public void testSentenceWithNoText() {
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.assertSentenceWithText("hello it is not me");
}
use of com.graphaware.nlp.util.TestAnnotatedText in project neo4j-nlp by graphaware.
the class TestAnnotatedTesterUnitTest method testSentenceWithText.
@Test
public void testSentenceWithText() {
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.assertSentenceWithText("hello it is me");
}
use of com.graphaware.nlp.util.TestAnnotatedText in project neo4j-nlp-stanfordnlp by graphaware.
the class TextProcessorTest method testPipelineWithCustomStopwordsDoNotAddNERDateToTheWord.
@Test
public void testPipelineWithCustomStopwordsDoNotAddNERDateToTheWord() {
String text = "In addition to the dollar the coinage act officially established monetary units of mill or one-thousandth of a dollar (symbol ₥), cent or one-hundredth of a dollar (symbol ¢), dime or one-tenth of a dollar, and eagle or ten dollars, with prescribed weights and composition of gold, silver, or copper for each.";
PipelineSpecification specification = new PipelineSpecification("customx", StanfordTextProcessor.class.getName());
specification.addProcessingStep("dependency");
specification.setStopWords("start, starts");
textProcessor.createPipeline(specification);
AnnotatedText annotatedText = textProcessor.annotateText(text, "en", specification);
TestAnnotatedText test = new TestAnnotatedText(annotatedText);
test.assertTagWithLemma("the");
test.assertNotTag(newTag("the", Collections.singletonList("DATE"), Collections.emptyList()));
}
Aggregations