Search in sources :

Example 6 with Sentence

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

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

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

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

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

Aggregations

Sentence (com.graphaware.nlp.domain.Sentence)18 AnnotatedText (com.graphaware.nlp.domain.AnnotatedText)14 Tag (com.graphaware.nlp.domain.Tag)9 Test (org.junit.Test)9 TestAnnotatedText (com.graphaware.nlp.util.TestAnnotatedText)7 TagUtils.newTag (com.graphaware.nlp.util.TagUtils.newTag)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Phrase (com.graphaware.nlp.domain.Phrase)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Node (org.neo4j.graphdb.Node)1