@Override public Iterator<T> iterator() { return JCasUtil.iterator(container, type, ambiguous, strict); } };
/** * Test if a JCas contains an annotation of the given type. * * @param <T> * the annotation type. * @param aJCas * a JCas. * @param aType * a annotation class. * @return {@code true} if there is at least one annotation of the given type in the JCas. */ public static <T extends TOP> boolean exists(JCas aJCas, Class<T> aType) { return JCasUtil.iterator(aJCas, aType).hasNext(); }
private Annotation hasAnnotation(JCas jcas, Class evidenceType) { Iterator annoIter = JCasUtil.iterator(jcas, evidenceType); if (annoIter.hasNext()) return (Annotation) annoIter.next(); return null; }
public static <T extends TOP> T getLast(JCas jcas, Class<T> type) { Iterator<T> iterator = JCasUtil.iterator(jcas, type); T last = null; while (iterator.hasNext()) { last = iterator.next(); } return last; }
public static Collection<Utterance> selectFullUtterances(JCas jcas) { final Iterator<Utterance> baseIterator = JCasUtil.iterator(jcas, Utterance.class); List<Utterance> fullUtterances = new ArrayList<Utterance>(); while (baseIterator.hasNext()) { Utterance utt = baseIterator.next(); if (!JCasUtil.selectCovered(jcas, Speaker.class, utt).isEmpty() && JCasUtil.selectCovered(jcas, Speaker.class, utt).get(0).getFigure() != null) fullUtterances.add(utt); } return fullUtterances; }
public static IntervalST<Integer> indexAnnotation(JCas jcas, Class<? extends Annotation> type, ArrayList<Annotation> annotations) { Iterator<? extends Annotation> annotationIter = JCasUtil.iterator(jcas, type); IntervalST<Integer> index = new IntervalST<>(); int i = 0; while (annotationIter.hasNext()) { Annotation annotation = type.cast(annotationIter.next()); annotations.add(annotation); // assume there is no overlapping annotations index.put(new Interval1D(annotation.getBegin(), annotation.getEnd()), i); i++; } return index; }
public static IntervalST<Annotation> indexAnnotation(JCas jcas, Class<? extends Annotation> type) { Iterator<? extends Annotation> annotationIter = JCasUtil.iterator(jcas, type); IntervalST<Annotation> index = new IntervalST<>(); while (annotationIter.hasNext()) { Annotation annotation = type.cast(annotationIter.next()); // assume there is no overlapping annotations index.put(new Interval1D(annotation.getBegin(), annotation.getEnd()), annotation); } return index; }
@Test public void testAthleteIsMadePersonOtherSource() throws AnalysisEngineProcessException, ResourceInitializationException { processJCas( TemplateFieldToEntityAnnotator.PARAM_ENTITY_TYPE, "common.Person", TemplateFieldToEntityAnnotator.PARAM_FIELD_NAME, "athlete", TemplateFieldToEntityAnnotator.PARAM_RECORD_NAME, "report", TemplateFieldToEntityAnnotator.PARAM_SOURCE, "ketchup"); assertFalse(JCasUtil.iterator(jCas, Person.class).hasNext()); } }