Search in sources :

Example 11 with TestAnnotatedText

use of com.graphaware.nlp.util.TestAnnotatedText in project neo4j-nlp-stanfordnlp by graphaware.

the class TextProcessorTest method testAnnotatedShortText.

@Test
public void testAnnotatedShortText() {
    AnnotatedText annotatedText = textProcessor.annotateText("Fixing Batch Endpoint Logging Problem", "en", PIPELINE_DEFAULT);
    assertEquals(1, annotatedText.getSentences().size());
    TestAnnotatedText test = new TestAnnotatedText(annotatedText);
    test.assertSentencesCount(1);
    test.assertTagsCountInSentence(5, 0);
}
Also used : TestAnnotatedText(com.graphaware.nlp.util.TestAnnotatedText) TestAnnotatedText(com.graphaware.nlp.util.TestAnnotatedText) Test(org.junit.Test)

Example 12 with TestAnnotatedText

use of com.graphaware.nlp.util.TestAnnotatedText in project neo4j-nlp-stanfordnlp by graphaware.

the class TextProcessorTest method testLemmaLowerCasing.

@Test
public void testLemmaLowerCasing() {
    String testText = "Collibra’s Data Governance Innovation: Enabling Data as a Strategic Asset";
    AnnotatedText annotatedText = textProcessor.annotateText(testText, "en", PIPELINE_DEFAULT);
    TestAnnotatedText test = new TestAnnotatedText(annotatedText);
    test.assertSentencesCount(1);
    assertEquals("governance", test.getTagAtPosition(0, 16).getLemma());
    PipelineSpecification pipelineSpecification = new PipelineSpecification("tokenizeWithTrueCase", StanfordTextProcessor.class.getName());
    pipelineSpecification.addProcessingStep("truecase");
    textProcessor.createPipeline(pipelineSpecification);
    annotatedText = textProcessor.annotateText(testText, "en", pipelineSpecification);
    test = new TestAnnotatedText(annotatedText);
    test.assertSentencesCount(1);
    assertEquals("governance", test.getTagAtPosition(0, 16).getLemma());
    assertEquals("Governance", test.getTagOccurrenceAtPosition(0, 16).getValue());
}
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