private static List<AnnotationFS> select(CAS cas, Type localType) { List<AnnotationFS> annotationFSs = new ArrayList<AnnotationFS>(); for(AnnotationFS annotationFS: CasUtil.select(cas, localType)){ annotationFSs.add(annotationFS); } return annotationFSs; }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { Collection<AnnotationFS> sequences = CasUtil.select(aJCas.getCas(), sequenceSpanType); for (AnnotationFS s : sequences) { int seqSize = CasUtil.selectCovered(aJCas.getCas(), instanceType, s).size(); if (seqSize > maximumLength) { maximumLength = seqSize; } } }
/** * Convenience method to iterator over all annotations. * * @param aCas * the CAS hosting the type system. * @return A collection of the selected type. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ public static Collection<AnnotationFS> selectAll(final CAS aCas) { return select(aCas, getType(aCas, CAS.TYPE_NAME_ANNOTATION)); }
private void removePredictions(CAS aCas, Type aPredictionType) { for (AnnotationFS fs : CasUtil.select(aCas, aPredictionType)) { aCas.removeFsFromIndexes(fs); } }
private static Collection<AnnotationFS> getAllAnnoFss(JCas aJcas, Type aType) { Collection<AnnotationFS> spanAnnos = select(aJcas.getCas(), aType); new ArrayList<>(spanAnnos).sort(Comparator.comparingInt(AnnotationFS::getBegin)); return spanAnnos; }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { int docSize = CasUtil.select(aJCas.getCas(), instanceType).size(); if (docSize > maximumLength) { maximumLength = docSize; } }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { int docSize = CasUtil.select(aJCas.getCas(), instanceType).size(); if (docSize > maximumLength) { maximumLength = docSize; } }
private static Collection<AnnotationFS> getAllAnnoFss(JCas aJcas, Type aType) { Collection<AnnotationFS> spanAnnos = select(aJcas.getCas(), aType); new ArrayList<>(spanAnnos).sort(Comparator.comparingInt(AnnotationFS::getBegin)); return spanAnnos; }
public static void clearAnnotations(JCas aJCas, Type aType) throws IOException { List<AnnotationFS> annotationsToRemove = new ArrayList<AnnotationFS>(); for (AnnotationFS a : select(aJCas.getCas(), aType)) { annotationsToRemove.add(a); } for (AnnotationFS annotation : annotationsToRemove) { aJCas.removeFsFromIndexes(annotation); } } }
public static void clearAnnotations(JCas aJCas, Type aType) throws IOException { List<AnnotationFS> annotationsToRemove = new ArrayList<>(); annotationsToRemove.addAll(select(aJCas.getCas(), aType)); for (AnnotationFS annotation : annotationsToRemove) { aJCas.removeFsFromIndexes(annotation); } }
private void collectInstances(JCas aJCas) { Collection<AnnotationFS> select = CasUtil.select(aJCas.getCas(), instanceType); for (AnnotationFS afs : select) { String instance = afs.getCoveredText(); token.add(instance); } }
private void collectInstances(JCas aJCas) { Collection<AnnotationFS> select = CasUtil.select(aJCas.getCas(), instanceType); for (AnnotationFS afs : select) { String instance = afs.getCoveredText(); token.add(instance); } }
private boolean annotationExists(CAS aCas, String aType) { Type type = aCas.getTypeSystem().getType(aType); if (CasUtil.select(aCas, type).size() == 0) { return false; } return true; }
public void process(JCas jCas) throws AnalysisEngineProcessException { CAS cas = jCas.getCas(); Type type = CasUtil.getAnnotationType(cas, printTypeName); Collection<AnnotationFS> annotations = CasUtil.select(cas, type); System.out.println(indication+"\n Here is a list of annotation '" + printTypeName + "':"); for (AnnotationFS annotation : annotations) { System.out.println(annotation.toString() + " Covered Text: \"" + annotation.getCoveredText() + "\""); } } }
private void mapInstances(JCas aJCas) { Collection<AnnotationFS> select = CasUtil.select(aJCas.getCas(), instanceType); for (AnnotationFS afs : select) { String instance = afs.getCoveredText(); if (instanceMap.containsKey(instance)) { continue; } instanceMap.put(afs.getCoveredText(), instanceIdx++); } }
private void removePredictedAnnotations(CAS aCas) { Type type = CasUtil.getType(aCas, getPredictedType()); for (AnnotationFS annotationFS : CasUtil.select(aCas, type)) { aCas.removeFsFromIndexes(annotationFS); } }
private void removePredictedAnnotations(CAS aCas) { Type type = CasUtil.getType(aCas, getPredictedType()); for (AnnotationFS annotationFS : CasUtil.select(aCas, type)) { aCas.removeFsFromIndexes(annotationFS); } }
private void addTCSequenceAnnotation(JCas jcas) { Type type = jcas.getCas().getTypeSystem().getType(nameSequence); Collection<AnnotationFS> sequenceAnnotation = CasUtil.select(jcas.getCas(), type); for (AnnotationFS seq : sequenceAnnotation) { TextClassificationSequence tcs = new TextClassificationSequence(jcas, seq.getBegin(), seq.getEnd()); tcs.addToIndexes(); } }
private void addTCSequenceAnnotation(JCas jcas) { Type type = jcas.getCas().getTypeSystem().getType(nameSequence); Collection<AnnotationFS> sequenceAnnotation = CasUtil.select(jcas.getCas(), type); for (AnnotationFS seq : sequenceAnnotation) { TextClassificationSequence tcs = new TextClassificationSequence(jcas, seq.getBegin(), seq.getEnd()); tcs.addToIndexes(); } }
private void addTcTargetAndOutcomeAnnotation(JCas aJCas) { Type type = aJCas.getCas().getTypeSystem().getType(targetName); Collection<AnnotationFS> unitAnnotation = CasUtil.select(aJCas.getCas(), type); for (AnnotationFS unit : unitAnnotation) { TextClassificationTarget tcs = new TextClassificationTarget(aJCas, unit.getBegin(), unit.getEnd()); tcs.addToIndexes(); TextClassificationOutcome tco = new TextClassificationOutcome(aJCas, unit.getBegin(), unit.getEnd()); tco.setOutcome(Constants.TC_OUTCOME_DUMMY_VALUE); tco.addToIndexes(); } }