private void process(JCas cas) throws AnalysisEngineProcessException { AnnotationIndex<Annotation> pmIndex = cas.getAnnotationIndex(PM.type); AnnotationIndex<Annotation> spanIdx = cas.getAnnotationIndex(spanAnnotationType); for (Annotation span : spanIdx) { process(cas, pmIndex, span); } }
public void buildSentenceBoundaryMap() { beginTreeMap = new TreeMap<Integer, Sentence>(); AnnotationIndex<Annotation> annotationIndex = jcas.getAnnotationIndex(Sentence.type); for (Annotation current : annotationIndex) { Sentence currentSentence = (Sentence)current; int begin = currentSentence.getBegin(); beginTreeMap.put(begin, currentSentence); } }
public static Annotation getAnnotation(JCas jcas, int typeID) { AnnotationIndex<Annotation> index = jcas.getAnnotationIndex(typeID); Iterator<Annotation> it = index.iterator(); Annotation annotation = null; if (it.hasNext()) { annotation = it.next(); } return annotation; }
HeidelTimeStandalone time = new HeidelTimeStandalone(Language.GERMAN, DocumentType.SCIENTIFIC, OutputType.XMI, "config.props", POSTagger.STANFORDPOSTAGGER); String xmiRepresentation = time.process(document, documentCreationTime); //Apply Heideltime and get the XML-UIMA representation JCas cas = jcasFactory.createJCas(); for(FSIterator<Annotation> it= cas.getAnnotationIndex(Timex3.type).iterator(); it.hasNext(); ){ System.out.printkn(it.next); }
public void buildSentenceBoundaryMap() { beginTreeMap = new TreeMap<Integer, Sentence>(); AnnotationIndex<Annotation> annotationIndex = jcas.getAnnotationIndex(Sentence.type); for (Annotation current : annotationIndex) { Sentence currentSentence = (Sentence)current; int begin = currentSentence.getBegin(); beginTreeMap.put(begin, currentSentence); } }
@Override public AnnotationIndex<Annotation> getAnnotationIndex(Type type) throws CASRuntimeException { testLiveness(); return delegate.getAnnotationIndex(type); }
@Override public AnnotationIndex<Annotation> getAnnotationIndex(int type) throws CASRuntimeException { testLiveness(); return delegate.getAnnotationIndex(type); }
@Override public <T extends Annotation> AnnotationIndex<T> getAnnotationIndex(Class<T> aClass) throws CASRuntimeException { testLiveness(); return delegate.getAnnotationIndex(aClass); }
private void removeOverlap(JCas jCas) { HashMap<String, IntervalST> typeSpanMap = new HashMap<>(); FSIndex annoIndex = jCas.getAnnotationIndex(); Iterator annoIter = annoIndex.iterator(); while (annoIter.hasNext()) { Object obj = annoIter.next(); String typeName = obj.getClass().getCanonicalName(); IntervalST thisSpanTree = typeSpanMap.getOrDefault(typeName, new IntervalST()); checkOverlap(thisSpanTree, (Annotation) obj); } }
private void indexAnnotations(JCas jCas) { for (Class conceptType : evidenceAnnotationTree.keySet()) { FSIndex annoIndex = jCas.getAnnotationIndex(conceptType); Iterator annoIter = annoIndex.iterator(); IntervalST<Annotation> intervalST = new IntervalST<>(); while (annoIter.hasNext()) { Annotation anno = (Annotation) annoIter.next(); intervalST.put(new Interval1D(anno.getBegin(), anno.getEnd()), anno); } evidenceAnnotationTree.put(conceptType, intervalST); } }
public String getId(JCas aJCas) { String id = ""; AnnotationIndex<Annotation> headerIndex = aJCas.getAnnotationIndex(Header.type); FSIterator<Annotation> headerIterator = headerIndex.iterator(); while (headerIterator.hasNext()) { Header header = (Header) headerIterator.next(); id = header.getDocId(); LOGGER.trace("Found id: " + id); } return id; }
public static Annotation getFirst(JCas jcas, Type type) { AnnotationIndex<Annotation> index = jcas.getAnnotationIndex(type); FSIterator<Annotation> iterator = index.iterator(); if (iterator.hasNext()) return (Annotation) iterator.next(); return null; }
public static Annotation getFirst(JCas jcas, Type type) { AnnotationIndex<Annotation> index = jcas.getAnnotationIndex(type); FSIterator<Annotation> iterator = index.iterator(); if (iterator.hasNext()) return (Annotation) iterator.next(); return null; }
private void extractAndSaveDocKey(JCas jcas, Document doc) { AnnotationIndex<Annotation> idx = jcas .getAnnotationIndex(DocKey.typeIndexID); FSIterator<Annotation> annoIterator = idx.iterator(); if (annoIterator.hasNext()) this.saveDocKey(doc, (DocKey) annoIterator.next()); }
/** * returns the number of annotations of specified type in the */ public static int countAnnotationsInSpan(JCas jcas, int type, int beginSpan, int endSpan) { Annotation ann = new Annotation(jcas, beginSpan, endSpan); ann.addToIndexes(); AnnotationIndex<?> annIdx = jcas.getAnnotationIndex(type); ann.removeFromIndexes(); return annIdx.size(); }
/** Find the sentence in which an Annotation lives **/ public static Sentence getSentence( JCas jCas, Annotation annot ) { FSIterator sentences = jCas.getAnnotationIndex(Sentence.type).iterator(); while (sentences.hasNext()) { Sentence sentence = (Sentence) sentences.next(); if (doesSubsume(sentence,annot)) { return sentence; } } return null; }
/** Returns the first ConllDependencyNode in the CAS w/ same begin and end as the given Annotation **/ public static ConllDependencyNode getDependencyNode(JCas jCas, Annotation annot) { AnnotationIndex nodeIndex = jCas.getAnnotationIndex(ConllDependencyNode.type); FSIterator nodeIterator = nodeIndex.iterator(); while (nodeIterator.hasNext()) { ConllDependencyNode node = (ConllDependencyNode) nodeIterator.next(); if (equalCoverage(annot,node)) { return node; } } return null; }
public static Annotation getFirst(JCas jcas, String typeName) { TypeSystem ts = jcas.getTypeSystem(); Type type = ts.getType(typeName); AnnotationIndex<Annotation> index = jcas.getAnnotationIndex(type); FSIterator<Annotation> iterator = index.iterator(); if (iterator.hasNext()) { return (Annotation) iterator.next(); } return null; }
public static IntervalST<Annotation> indexAnnotation(JCas jcas, int typeId) { FSIndex annoIndex = jcas.getAnnotationIndex(typeId); FSIterator annoIter = annoIndex.iterator(); IntervalST<Annotation> index = new IntervalST<>(); while (annoIter.hasNext()) { Annotation annotation = (Annotation) annoIter.next(); // assume there is no overlapping annotations index.put(new Interval1D(annotation.getBegin(), annotation.getEnd()), annotation); } return index; }
private void addHeadAnnotation(Constituent cons, Span headSpan) throws CASRuntimeException, CASException { FSIterator tokens = cons.getCAS().getJCas().getAnnotationIndex(Token.type).subiterator(cons); int headStart = offsetMap.getMapping(headSpan.getStart()); int headEnd = offsetMap.getMapping(headSpan.getEnd()); while (tokens.hasNext()) { Token token = (Token) tokens.next(); if (token.getBegin() == headStart && token.getEnd() == headEnd) { cons.setHead(token); tokens.moveToLast(); tokens.next(); } } }