Search in sources :

Example 1 with EntityAnnotation

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

Aggregations

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