Search in sources :

Example 1 with DummySentimentAnnotation

use of org.apache.solr.uima.ts.DummySentimentAnnotation 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();
            }
        }
    }
}
Also used : TokenAnnotation(org.apache.uima.TokenAnnotation) DummySentimentAnnotation(org.apache.solr.uima.ts.DummySentimentAnnotation) Annotation(org.apache.uima.jcas.tcas.Annotation) DummySentimentAnnotation(org.apache.solr.uima.ts.DummySentimentAnnotation) TokenAnnotation(org.apache.uima.TokenAnnotation)

Example 2 with DummySentimentAnnotation

use of org.apache.solr.uima.ts.DummySentimentAnnotation in project lucene-solr by apache.

the class DummySentimentAnnotator method createSentimentAnnotation.

private DummySentimentAnnotation createSentimentAnnotation(JCas jcas, Annotation annotation) {
    DummySentimentAnnotation dummySentimentAnnotation = new DummySentimentAnnotation(jcas);
    dummySentimentAnnotation.setBegin(annotation.getBegin());
    dummySentimentAnnotation.setEnd(annotation.getEnd());
    return dummySentimentAnnotation;
}
Also used : DummySentimentAnnotation(org.apache.solr.uima.ts.DummySentimentAnnotation)

Aggregations

DummySentimentAnnotation (org.apache.solr.uima.ts.DummySentimentAnnotation)2 TokenAnnotation (org.apache.uima.TokenAnnotation)1 Annotation (org.apache.uima.jcas.tcas.Annotation)1