use of org.apache.uima.TokenAnnotation in project lucene-solr by apache.
the class DummySentimentAnnotator method process.
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
for (Annotation annotation : jcas.getAnnotationIndex(TokenAnnotation.type)) {
String tokenPOS = ((TokenAnnotation) annotation).getPosTag();
if ("jj".equals(tokenPOS)) {
if (Arrays.asList(positiveAdj).contains(annotation.getCoveredText())) {
DummySentimentAnnotation dummySentimentAnnotation = createSentimentAnnotation(jcas, annotation);
dummySentimentAnnotation.setMood("positive");
dummySentimentAnnotation.addToIndexes();
} else if (Arrays.asList(negativeAdj).contains(annotation.getCoveredText())) {
DummySentimentAnnotation dummySentimentAnnotation = createSentimentAnnotation(jcas, annotation);
dummySentimentAnnotation.setMood("negative");
dummySentimentAnnotation.addToIndexes();
}
}
}
}
use of org.apache.uima.TokenAnnotation in project lucene-solr by apache.
the class SampleEntityAnnotator method process.
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
Type type = jcas.getCas().getTypeSystem().getType(TYPE_NAME);
Feature entityFeature = type.getFeatureByBaseName(ENTITY_FEATURE);
Feature nameFeature = type.getFeatureByBaseName(NAME_FEATURE);
for (Annotation annotation : jcas.getAnnotationIndex(TokenAnnotation.type)) {
String tokenPOS = ((TokenAnnotation) annotation).getPosTag();
if (NP.equals(tokenPOS) || NPS.equals(tokenPOS)) {
AnnotationFS entityAnnotation = jcas.getCas().createAnnotation(type, annotation.getBegin(), annotation.getEnd());
entityAnnotation.setStringValue(entityFeature, annotation.getCoveredText());
// "OTHER" makes no sense. In practice, "PERSON", "COUNTRY", "E-MAIL", etc.
String name = "OTHER";
if (annotation.getCoveredText().equals("Apache"))
name = "ORGANIZATION";
entityAnnotation.setStringValue(nameFeature, name);
jcas.addFsToIndexes(entityAnnotation);
}
}
}
use of org.apache.uima.TokenAnnotation in project lucene-solr by apache.
the class DummyEntityAnnotator method process.
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
for (Annotation annotation : jcas.getAnnotationIndex(TokenAnnotation.type)) {
String tokenPOS = ((TokenAnnotation) annotation).getPosTag();
if ("np".equals(tokenPOS) || "nps".equals(tokenPOS)) {
EntityAnnotation entityAnnotation = new EntityAnnotation(jcas);
entityAnnotation.setBegin(annotation.getBegin());
entityAnnotation.setEnd(annotation.getEnd());
String entityString = annotation.getCoveredText();
entityAnnotation.setEntity(entityString);
// "OTHER" makes no sense. In practice, "PERSON", "COUNTRY", "E-MAIL", etc.
String name = "OTHER";
if (entityString.equals("Apache"))
name = "ORGANIZATION";
entityAnnotation.setName(name);
entityAnnotation.addToIndexes();
}
}
}
Aggregations