private void addChunkAnnotation(CAS tcas, AnnotationFS[] tokenAnnotations, String tag, int start, int end) { AnnotationFS chunk = tcas.createAnnotation(mChunkType, tokenAnnotations[start].getBegin(), tokenAnnotations[end - 1].getEnd()); chunk.setStringValue(mChunkFeature, tag); tcas.getIndexRepository().addFS(chunk); }
+ tokenSpans[i].getEnd()); cas.getIndexRepository().addFS(tokenAnnotations[i]);
cas.getIndexRepository().addFS(nameAnnotations[i]);
@Override protected void setBestCategory(CAS tcas, String bestCategory) { FSIndex<AnnotationFS> categoryIndex = tcas.getAnnotationIndex(mCategoryType); AnnotationFS categoryAnnotation; if (categoryIndex.size() > 0) { categoryAnnotation = categoryIndex.iterator().next(); } else { categoryAnnotation = tcas.createAnnotation(mCategoryType, 0, tcas.getDocumentText().length()); tcas.getIndexRepository().addFS(categoryAnnotation); } categoryAnnotation.setStringValue(mCategoryFeature, bestCategory); } }
protected AnnotationFS createAnnotation(CAS cas, int offset, Parse parse) { Parse[] parseChildren = parse.getChildren(); AnnotationFS[] parseChildAnnotations = new AnnotationFS[parseChildren.length]; // do this for all children for (int i = 0; i < parseChildren.length; i++) { parseChildAnnotations[i] = createAnnotation(cas, offset, parseChildren[i]); } AnnotationFS parseAnnotation = cas.createAnnotation(mParseType, offset + parse.getSpan().getStart(), offset + parse.getSpan().getEnd()); parseAnnotation.setStringValue(mTypeFeature, parse.getType()); if (probabilityFeature != null) { parseAnnotation.setDoubleValue(probabilityFeature, parse.getProb()); } ArrayFS childrenArray = cas.createArrayFS(parseChildAnnotations.length); childrenArray.copyFromArray(parseChildAnnotations, 0, 0, parseChildAnnotations.length); parseAnnotation.setFeatureValue(childrenFeature, childrenArray); cas.getIndexRepository().addFS(parseAnnotation); return parseAnnotation; }
sentPositions[i].getEnd() + containerAnnotation.getBegin()); cas.getIndexRepository().addFS(sentences[i]);
public static IndexInfo[] getIndexes(CAS cas) { Iterator<String> it = cas.getIndexRepository().getLabels(); List<IndexInfo> ll = new ArrayList<IndexInfo>(); while (it.hasNext()) { ll.add(new IndexInfo(cas, it.next())); } return ll.toArray(new IndexInfo[ll.size()]); }
/** * Internally removes an annotation from the {@link CAS}. * * @param featureStructure the feature structure */ private void removeAnnotationInternal(FeatureStructure featureStructure) { getCAS().getIndexRepository().removeFS(featureStructure); }
/** * Internally removes an annotation from the {@link CAS}. * * @param featureStructure the feature structure */ private void addFeatureStructureInternal(FeatureStructure featureStructure) { getCAS().getIndexRepository().addFS(featureStructure); }
public static Set<FeatureStructure> collectIndexed(CAS aCas) { LowLevelCAS llcas = aCas.getLowLevelCAS(); Set<FeatureStructure> fses = new TreeSet<>(Comparator.comparingInt(llcas::ll_getFSRef)); FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS( aCas.getTypeSystem().getTopType()); i.forEachRemaining(fses::add); return fses; }
public static Set<FeatureStructure> collectReachable(CAS aCas) { LowLevelCAS llcas = aCas.getLowLevelCAS(); Set<FeatureStructure> fses = new TreeSet<>(Comparator.comparingInt(llcas::ll_getFSRef)); FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS( aCas.getTypeSystem().getTopType()); i.forEachRemaining(fs -> collect(fses, fs)); return fses; }
public Object getSubTypes() { FSIndexRepository ir = cas.getIndexRepository(); Type type = fsIndex.getType(); List<Type> subtypes = cas.getTypeSystem().getProperlySubsumedTypes(type); DebugNameValuePair[] r = new DebugNameValuePair[subtypes.size()]; int i = 0; Iterator<Type> it = subtypes.iterator(); while (it.hasNext()) { Type stype = it.next(); r[i++] = new DebugNameValuePair("Type: " + stype.getName(), new UnexpandedFeatureStructures(ir.getIndex(indexName, stype))); } return r; }
public static Set<FeatureStructure> collectIndexed(CAS aCas) { LowLevelCAS llcas = aCas.getLowLevelCAS(); Set<FeatureStructure> fses = new TreeSet<>((fs1, fs2) -> llcas.ll_getFSRef(fs1) - llcas.ll_getFSRef(fs2)); FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS( aCas.getTypeSystem().getTopType()); i.forEachRemaining(fs -> fses.add(fs)); return fses; }
public static Set<FeatureStructure> collectIndexed(CAS aCas) { LowLevelCAS llcas = aCas.getLowLevelCAS(); Set<FeatureStructure> fses = new TreeSet<>((fs1, fs2) -> llcas.ll_getFSRef(fs1) - llcas.ll_getFSRef(fs2)); FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS( aCas.getTypeSystem().getTopType()); i.forEachRemaining(fs -> fses.add(fs)); return fses; }
private void addChunkAnnotation(CAS tcas, AnnotationFS[] tokenAnnotations, String tag, int start, int end) { AnnotationFS chunk = tcas.createAnnotation(mChunkType, tokenAnnotations[start].getBegin(), tokenAnnotations[end - 1].getEnd()); chunk.setStringValue(mChunkFeature, tag); tcas.getIndexRepository().addFS(chunk); }
/** * Returns {@code true} if {@code jCas} contains {@link WebArgumentMetadata} * * @param jCas jCas * @return boolean */ public static boolean hasWebArgumentMetadata(final JCas jCas) { FSIterator<FeatureStructure> iterator = jCas.getCas().getIndexRepository().getAllIndexedFS( CasUtil.getType(jCas.getCas(), WebArgumentMetadata.class)); return iterator.hasNext(); }
public static Set<FeatureStructure> collectReachable(CAS aCas) { LowLevelCAS llcas = aCas.getLowLevelCAS(); Set<FeatureStructure> fses = new TreeSet<>((fs1, fs2) -> llcas.ll_getFSRef(fs1) - llcas.ll_getFSRef(fs2)); FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS( aCas.getTypeSystem().getTopType()); i.forEachRemaining(fs -> collect(fses, fs)); return fses; }
public static Set<FeatureStructure> collectReachable(CAS aCas) { LowLevelCAS llcas = aCas.getLowLevelCAS(); Set<FeatureStructure> fses = new TreeSet<>((fs1, fs2) -> llcas.ll_getFSRef(fs1) - llcas.ll_getFSRef(fs2)); FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS( aCas.getTypeSystem().getTopType()); i.forEachRemaining(fs -> collect(fses, fs)); return fses; }
@Override protected void setBestCategory(CAS tcas, String bestCategory) { FSIndex<AnnotationFS> categoryIndex = tcas.getAnnotationIndex(mCategoryType); AnnotationFS categoryAnnotation; if (categoryIndex.size() > 0) { categoryAnnotation = categoryIndex.iterator().next(); } else { categoryAnnotation = tcas.createAnnotation(mCategoryType, 0, tcas.getDocumentText().length()); tcas.getIndexRepository().addFS(categoryAnnotation); } categoryAnnotation.setStringValue(mCategoryFeature, bestCategory); } }
public static void copyFeatureStructuresOfType(String typeName, CAS sourceView, CAS destinationView) { FeatureStructureCopyingQueue featureStructureCopyingQueue = new FeatureStructureCopyingQueue( sourceView, destinationView); FSIterator<FeatureStructure> iterator = sourceView.getIndexRepository() .getAllIndexedFS(sourceView.getTypeSystem().getType(typeName)); while (iterator.hasNext()) { FeatureStructure featureStructure = iterator.get(); featureStructureCopyingQueue.enqueue(featureStructure); } featureStructureCopyingQueue.run(); }