use of com.graphaware.nlp.domain.Sentence in project neo4j-nlp by graphaware.
the class AnnotatedTextPersister method iterateSentencesAndStore.
private void iterateSentencesAndStore(Node annotatedTextNode, AnnotatedText annotatedText, String id, String txId) {
final AtomicReference<Node> previousSentenceReference = new AtomicReference<>();
annotatedText.getSentences().sort((Sentence o1, Sentence o2) -> o1.compareTo(o2));
annotatedText.getSentences().forEach((sentence) -> {
Node sentenceNode = getPersister(Sentence.class).persist(sentence, id, txId);
Node previousSentence = previousSentenceReference.get();
boolean isFirstSentence = previousSentence == null;
relateSentenceToAnnotatedText(sentenceNode, annotatedTextNode, isFirstSentence);
if (!isFirstSentence) {
relatePreviousSentenceToNext(previousSentence, sentenceNode);
}
previousSentenceReference.set(sentenceNode);
});
}
use of com.graphaware.nlp.domain.Sentence in project neo4j-nlp by graphaware.
the class TestAnnotatedText method assertSentenceWithText.
public void assertSentenceWithText(String text) {
boolean found = false;
for (Sentence sentence : annotatedText.getSentences()) {
if (sentence.getSentence().equals(text)) {
found = true;
}
}
assertTrue(found);
}
use of com.graphaware.nlp.domain.Sentence in project neo4j-nlp by graphaware.
the class TestAnnotatedText method assertTagsCountInSentence.
public void assertTagsCountInSentence(int count, int sentenceNumber) {
Sentence sentence = annotatedText.getSentencesSorted().get(sentenceNumber);
assertEquals(count, sentence.getTags().size());
}
use of com.graphaware.nlp.domain.Sentence in project neo4j-nlp by graphaware.
the class TestAnnotatedText method assertTagWithLemma.
public void assertTagWithLemma(String value) {
boolean found = false;
for (Sentence sentence : annotatedText.getSentences()) {
for (Tag tag : sentence.getTags().values()) {
if (tag.getLemma().equals(value)) {
found = true;
break;
}
}
}
assertTrue(found);
}
use of com.graphaware.nlp.domain.Sentence in project neo4j-nlp by graphaware.
the class AnnotatedTextTest method testComplexFilter.
@Test
public void testComplexFilter() {
AnnotatedText annotatedText = new AnnotatedText();
Sentence sentence = new Sentence("Owen Bennet Jones is working for the BBC in Pakistan", 0);
sentence.addTag(getTag("Owen Bennet Jones", "PERSON"));
sentence.addTag(getTag("work", null));
sentence.addTag(getTag("the", null));
sentence.addTag(getTag("BBC", null));
sentence.addTag(getTag("Pakistan", "LOCATION"));
annotatedText.addSentence(sentence);
assertTrue(annotatedText.filter("Owen Bennet Jones/PERSON,BBC,Pakistan/LOCATION"));
}
Aggregations