use of edu.stanford.nlp.util.ArrayCoreMap in project CoreNLP by stanfordnlp.
the class MorphaAnnotatorITest method testSentencesAnnotation.
public void testSentencesAnnotation() throws Exception {
List<CoreLabel> words = getTestWords();
CoreMap sentence = new ArrayCoreMap();
sentence.set(CoreAnnotations.TokensAnnotation.class, words);
List<CoreMap> sentences = new ArrayList<CoreMap>();
sentences.add(sentence);
Annotation document = new Annotation(text);
document.set(CoreAnnotations.SentencesAnnotation.class, sentences);
shortPipeline.annotate(document);
checkResult(words);
}
use of edu.stanford.nlp.util.ArrayCoreMap in project CoreNLP by stanfordnlp.
the class POSTaggerAnnotatorITest method testMultipleSentencesAnnotation.
/**
* Test that multiple sentences work for the SentenceAnnotation.
*/
public void testMultipleSentencesAnnotation() {
List<CoreLabel> firstLabels = makeSentence(testSentences[0]);
List<CoreLabel> secondLabels = makeSentence(testSentences[1]);
CoreMap firstSentence = new ArrayCoreMap();
firstSentence.set(CoreAnnotations.TokensAnnotation.class, firstLabels);
CoreMap secondSentence = new ArrayCoreMap();
secondSentence.set(CoreAnnotations.TokensAnnotation.class, secondLabels);
List<CoreMap> sentences = new ArrayList<>();
sentences.add(firstSentence);
sentences.add(secondSentence);
Annotation annotation = new Annotation(longText);
annotation.set(CoreAnnotations.SentencesAnnotation.class, sentences);
tagger.annotate(annotation);
checkLabels(firstLabels, "PRP$", "NN", "VBZ", "JJ", "CC", "JJ", ".");
checkLabels(secondLabels, "DT", "VBZ", "DT", "JJ", "NN", ".");
}
use of edu.stanford.nlp.util.ArrayCoreMap in project CoreNLP by stanfordnlp.
the class POSTaggerAnnotatorITest method makeSentenceCoreMap.
private static CoreMap makeSentenceCoreMap(String sentence) {
List<CoreLabel> tokens = makeSentence(sentence);
CoreMap map = new ArrayCoreMap(1);
map.set(CoreAnnotations.TokensAnnotation.class, tokens);
return map;
}
use of edu.stanford.nlp.util.ArrayCoreMap in project CoreNLP by stanfordnlp.
the class RegexNERAnnotatorITest method testOverwrite.
/**
* Neither the LOCATION nor the ORGANIZATION tags should be overridden, since both
* Ontario (STATE_OR_PROVINCE) and American (NATIONALITY) do not span the entire
* phrase that is NamedEntityTag-annotated.
*/
public void testOverwrite() {
String str = "I like Ontario Place , and I like the Native American Church , too .";
String[] split = str.split(" ");
List<CoreLabel> tokens = SentenceUtils.toCoreLabelList(split);
tokens.get(2).set(CoreAnnotations.NamedEntityTagAnnotation.class, "LOCATION");
tokens.get(3).set(CoreAnnotations.NamedEntityTagAnnotation.class, "LOCATION");
tokens.get(9).set(CoreAnnotations.NamedEntityTagAnnotation.class, "ORGANIZATION");
tokens.get(10).set(CoreAnnotations.NamedEntityTagAnnotation.class, "ORGANIZATION");
tokens.get(11).set(CoreAnnotations.NamedEntityTagAnnotation.class, "ORGANIZATION");
CoreMap sentence = new ArrayCoreMap();
sentence.set(CoreAnnotations.TokensAnnotation.class, tokens);
List<CoreMap> sentences = new ArrayList<CoreMap>();
sentences.add(sentence);
Annotation corpus = new Annotation("I like Ontario Place, and I like the Native" + "American Church, too.");
corpus.set(CoreAnnotations.SentencesAnnotation.class, sentences);
annotator.annotate(corpus);
checkTags(tokens, "O", "O", "LOCATION", "LOCATION", "O", "O", "O", "O", "O", "RELIGION", "RELIGION", "RELIGION", "O", "O", "O");
}
use of edu.stanford.nlp.util.ArrayCoreMap in project CoreNLP by stanfordnlp.
the class RegexNERAnnotatorITest method testPriority.
/**
* In the mapping file, Christianity is assigned a higher priority than Early Christianity,
* and so Early should not be marked as RELIGION.
*/
public void testPriority() {
String str = "Christianity is of higher regex priority than Early Christianity . ";
String[] split = str.split(" ");
List<CoreLabel> tokens = SentenceUtils.toCoreLabelList(split);
CoreMap sentence = new ArrayCoreMap();
sentence.set(CoreAnnotations.TokensAnnotation.class, tokens);
List<CoreMap> sentences = new ArrayList<CoreMap>();
sentences.add(sentence);
Annotation corpus = new Annotation("Christianity is of higher regex priority than Early " + "Christianity. ");
corpus.set(CoreAnnotations.SentencesAnnotation.class, sentences);
annotator.annotate(corpus);
checkTags(tokens, "RELIGION", "O", "O", "O", "O", "O", "O", "O", "RELIGION", "O");
}
Aggregations