![JAR search and dependency download from the Maven repository](/logo.png)
eu.project.ttc.models.TermSuiteCas Maven / Gradle / Ivy
package eu.project.ttc.models;
import java.util.Iterator;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;
import eu.project.ttc.types.SourceDocumentInformation;
import eu.project.ttc.types.TermOccAnnotation;
import eu.project.ttc.types.WordAnnotation;
import eu.project.ttc.utils.IteratorUtils;
import eu.project.ttc.utils.JCasUtils;
/**
* A wrapper for a {@link JCas} aiming at providing an easy access API
* to TermSuite annotations for end-users.
*
* @author Damien Cram
*
*/
public class TermSuiteCas {
private JCas uimaCas;
public TermSuiteCas(JCas uimaCas) {
super();
this.uimaCas = uimaCas;
}
/**
*
* @return the inner UIMA {@link JCas} object
*/
public JCas getUimaCas() {
return this.uimaCas;
}
public SourceDocumentInformation getSourceDocumentInformation() {
return JCasUtils.getSourceDocumentAnnotation(this.uimaCas).get();
}
public Iterable getWordAnnotations() {
return IteratorUtils.toIterable(wordAnnotationIt());
}
public Iterable getSubWordAnnotations(TermOccAnnotation termOcc) {
return JCasUtil.subiterate(getUimaCas(), WordAnnotation.class, termOcc, false, true);
}
public Iterator wordAnnotationIt() {
return annoIterator(WordAnnotation.type);
}
@SuppressWarnings("unchecked")
private Iterator annoIterator(int type) {
return (Iterator)getUimaCas().getAnnotationIndex(type).iterator();
}
public Iterable getTermOccAnnotations() {
return IteratorUtils.toIterable(termOccAnnotationIt());
}
public Iterable getSubTermOccAnnotations(TermOccAnnotation termOcc) {
return JCasUtil.subiterate(getUimaCas(), TermOccAnnotation.class, termOcc, false, true);
}
public Iterator termOccAnnotationIt() {
return annoIterator(TermOccAnnotation.type);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy