Search in sources :

Example 6 with TestAnnotatedText

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"));
}
Also used : TestAnnotatedText(com.graphaware.nlp.util.TestAnnotatedText) AnnotatedText(com.graphaware.nlp.domain.AnnotatedText) TestAnnotatedText(com.graphaware.nlp.util.TestAnnotatedText) Sentence(com.graphaware.nlp.domain.Sentence) Test(org.junit.Test)

Example 7 with TestAnnotatedText

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");
}
Also used : TestAnnotatedText(com.graphaware.nlp.util.TestAnnotatedText) AnnotatedText(com.graphaware.nlp.domain.AnnotatedText) TestAnnotatedText(com.graphaware.nlp.util.TestAnnotatedText) TagUtils.newTag(com.graphaware.nlp.util.TagUtils.newTag) Tag(com.graphaware.nlp.domain.Tag) Sentence(com.graphaware.nlp.domain.Sentence) Test(org.junit.Test)

Example 8 with TestAnnotatedText

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");
}
Also used : TestAnnotatedText(com.graphaware.nlp.util.TestAnnotatedText) AnnotatedText(com.graphaware.nlp.domain.AnnotatedText) TestAnnotatedText(com.graphaware.nlp.util.TestAnnotatedText) TagUtils.newTag(com.graphaware.nlp.util.TagUtils.newTag) Tag(com.graphaware.nlp.domain.Tag) Sentence(com.graphaware.nlp.domain.Sentence) Test(org.junit.Test)

Example 9 with TestAnnotatedText

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");
}
Also used : TestAnnotatedText(com.graphaware.nlp.util.TestAnnotatedText) AnnotatedText(com.graphaware.nlp.domain.AnnotatedText) TestAnnotatedText(com.graphaware.nlp.util.TestAnnotatedText) TagUtils.newTag(com.graphaware.nlp.util.TagUtils.newTag) Tag(com.graphaware.nlp.domain.Tag) Sentence(com.graphaware.nlp.domain.Sentence) Test(org.junit.Test)

Example 10 with TestAnnotatedText

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()));
}
Also used : PipelineSpecification(com.graphaware.nlp.dsl.request.PipelineSpecification) TestAnnotatedText(com.graphaware.nlp.util.TestAnnotatedText) TestAnnotatedText(com.graphaware.nlp.util.TestAnnotatedText) StanfordTextProcessor(com.graphaware.nlp.processor.stanford.StanfordTextProcessor) Test(org.junit.Test)

Aggregations

TestAnnotatedText (com.graphaware.nlp.util.TestAnnotatedText)12 Test (org.junit.Test)12 AnnotatedText (com.graphaware.nlp.domain.AnnotatedText)8 Sentence (com.graphaware.nlp.domain.Sentence)7 Tag (com.graphaware.nlp.domain.Tag)5 TagUtils.newTag (com.graphaware.nlp.util.TagUtils.newTag)5 PipelineSpecification (com.graphaware.nlp.dsl.request.PipelineSpecification)2 StanfordTextProcessor (com.graphaware.nlp.processor.stanford.StanfordTextProcessor)2