Search in sources :

Example 11 with AnnotatedText

use of com.graphaware.nlp.domain.AnnotatedText 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"));
}
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 12 with AnnotatedText

use of com.graphaware.nlp.domain.AnnotatedText 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");
}
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 13 with AnnotatedText

use of com.graphaware.nlp.domain.AnnotatedText 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 14 with AnnotatedText

use of com.graphaware.nlp.domain.AnnotatedText 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 15 with AnnotatedText

use of com.graphaware.nlp.domain.AnnotatedText 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)

Aggregations

AnnotatedText (com.graphaware.nlp.domain.AnnotatedText)32 Test (org.junit.Test)18 Sentence (com.graphaware.nlp.domain.Sentence)17 Tag (com.graphaware.nlp.domain.Tag)11 TextProcessor (com.graphaware.nlp.processor.TextProcessor)9 TestAnnotatedText (com.graphaware.nlp.util.TestAnnotatedText)8 NLPIntegrationTest (com.graphaware.nlp.NLPIntegrationTest)5 TagUtils.newTag (com.graphaware.nlp.util.TagUtils.newTag)5 TestNLPGraph (com.graphaware.nlp.util.TestNLPGraph)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 Transaction (org.neo4j.graphdb.Transaction)5 StanfordTextProcessor (com.graphaware.nlp.processor.stanford.StanfordTextProcessor)3 StubTextProcessor (com.graphaware.nlp.stub.StubTextProcessor)3 StanfordCoreNLP (edu.stanford.nlp.pipeline.StanfordCoreNLP)3 Arrays (java.util.Arrays)3 Collections (java.util.Collections)3 Assert (org.junit.Assert)3 Before (org.junit.Before)3 Node (org.neo4j.graphdb.Node)3 PipelineSpecification (com.graphaware.nlp.dsl.request.PipelineSpecification)2