public <T extends TOP> FSIterator<T> getAllIndexedFS(Type aType) { return fsIndexRepository.getAllIndexedFS(aType); }
public <T extends TOP> FSIterator<T> getAllIndexedFS(int aType) { return fsIndexRepository.getAllIndexedFS(jcas.getCasType(aType)); } }
@Override public <T extends TOP> FSIterator<T> getAllIndexedFS(Class<T> clazz) { return getFSIndexRepository().getAllIndexedFS(getCasType(clazz)); }
/** * Get the {@link de.tudarmstadt.ukp.dkpro.argumentation.types.WebArgumentMetadata} from the JCas. * * @throws IllegalArgumentException if no {@link DocumentMetaData} exists in the jCas */ public static WebArgumentMetadata get(final JCas jCas) { FSIterator<FeatureStructure> iterator = jCas.getCas().getIndexRepository().getAllIndexedFS( CasUtil.getType(jCas.getCas(), WebArgumentMetadata.class)); if (!iterator.hasNext()) { throw new IllegalArgumentException(new Throwable("CAS does not contain any " + WebArgumentMetadata.class.getName())); } WebArgumentMetadata result = (WebArgumentMetadata) iterator.next(); if (iterator.hasNext()) { throw new IllegalArgumentException(new Throwable("CAS contains more than one " + WebArgumentMetadata.class.getName())); } return result; }
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; }
/** * Get the {@link DocumentAnnotation} from the CAS if it already exists. * * @param aCas * a CAS. * @return the {@link DocumentAnnotation} from the CAS. */ private static DocumentAnnotation getDocumentAnnotation(final CAS aCas) { FSIterator<FeatureStructure> iterator = aCas.getIndexRepository() .getAllIndexedFS(CasUtil.getType(aCas, DocumentAnnotation.class)); if (!iterator.hasNext()) { return null; } DocumentAnnotation result = (DocumentAnnotation) iterator.next(); if (iterator.hasNext()) { throw new IllegalArgumentException(new Throwable( "CAS contains more than one " + DocumentAnnotation.class.getName())); } return result; }
/** * Get the {@link DocumentAnnotation} from the CAS if it already exists. * * @param aCas * a CAS. * @return the {@link DocumentAnnotation} from the CAS. */ private static DocumentAnnotation getDocumentAnnotation(final CAS aCas) { FSIterator<FeatureStructure> iterator = aCas.getIndexRepository() .getAllIndexedFS(CasUtil.getType(aCas, DocumentAnnotation.class)); if (!iterator.hasNext()) { return null; } DocumentAnnotation result = (DocumentAnnotation) iterator.next(); if (iterator.hasNext()) { throw new IllegalArgumentException(new Throwable( "CAS contains more than one " + DocumentAnnotation.class.getName())); } return result; }
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 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; }
@Override public Object[] getElements(Object inputElement) { if (mCurrentType == null) { return new Object[] {}; } StrictTypeConstraint typeConstrain = new StrictTypeConstraint(mCurrentType); FSIterator<FeatureStructure> strictTypeIterator =mDocument.getCAS().createFilteredIterator( mDocument.getCAS().getIndexRepository().getAllIndexedFS(mCurrentType), typeConstrain); LinkedList<ModelFeatureStructure> featureStrucutreList = new LinkedList<ModelFeatureStructure>(); while (strictTypeIterator.hasNext()) { featureStrucutreList.add(new ModelFeatureStructure(mDocument, strictTypeIterator.next())); } ModelFeatureStructure[] featureStructureArray = new ModelFeatureStructure[featureStrucutreList .size()]; featureStrucutreList.toArray(featureStructureArray); return featureStructureArray; }
public static Map<FeatureStructure, FeatureStructure> getNonIndexedFSesWithOwner(CAS aCas) { TypeSystem ts = aCas.getTypeSystem(); LowLevelCAS llcas = aCas.getLowLevelCAS(); Set<FeatureStructure> allIndexedFS = collectIndexed(aCas); Map<FeatureStructure, FeatureStructure> allReachableFS = new TreeMap<>((fs1, fs2) -> llcas.ll_getFSRef(fs1) - llcas.ll_getFSRef(fs2)); FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS( aCas.getTypeSystem().getTopType()); i.forEachRemaining(fs -> collect(allReachableFS, allIndexedFS, fs, fs)); // Remove all that are not annotations allReachableFS.entrySet() .removeIf(e -> !ts.subsumes(aCas.getAnnotationType(), e.getKey().getType())); // Remove all that are indexed allReachableFS.entrySet().removeIf(e -> e.getKey() == e.getValue()); // All that is left are non-index annotations return allReachableFS; } }
/** * Get the single instance of the specified type from the JCas. * * @param cas * a CAS containing the annotation. * @param type * a UIMA type. * @return the single instance of the given type. throws IllegalArgumentException if not exactly * one instance if the given type is present. */ public static FeatureStructure selectSingle(CAS cas, Type type) { FSIterator<FeatureStructure> iterator = cas.getIndexRepository().getAllIndexedFS(type); if (!iterator.hasNext()) { throw new IllegalArgumentException("CAS does not contain any [" + type.getName() + "]"); } FeatureStructure result = iterator.next(); if (iterator.hasNext()) { throw new IllegalArgumentException("CAS contains more than one [" + type.getName() + "]"); } return result; }
/** * 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; }
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(); }
private List<StyleMapEntry> createStyleList(JCas jcas) { List<StyleMapEntry> result = new ArrayList<StyleMapEntry>(); Type type = jcas.getCasType(RutaColoring.type); FSIterator<FeatureStructure> iterator = jcas.getFSIndexRepository().getAllIndexedFS(type); while (iterator.hasNext()) { RutaColoring each = (RutaColoring) iterator.next(); StyleMapEntry entry = new StyleMapEntry(); entry.setAnnotationTypeName(each.getTargetType()); String fgColor = each.getFgColor(); entry.setForeground(parseColorBackground(fgColor)); String bgColor = each.getBgColor(); entry.setBackground(parseColorBackground(bgColor)); entry.setChecked(each.getSelected()); result.add(entry); } return result; }
private List<StyleMapEntry> createStyleList(JCas jcas) { List<StyleMapEntry> result = new ArrayList<StyleMapEntry>(); Type type = jcas.getCasType(TextMarkerColoring.type); FSIterator<FeatureStructure> iterator = jcas.getFSIndexRepository().getAllIndexedFS(type); while (iterator.hasNext()) { TextMarkerColoring each = (TextMarkerColoring) iterator.next(); StyleMapEntry entry = new StyleMapEntry(); entry.setAnnotationTypeName(each.getTargetType()); String fgColor = each.getFgColor(); entry.setForeground(parseColorBackground(fgColor)); String bgColor = each.getBgColor(); entry.setBackground(parseColorBackground(bgColor)); entry.setChecked(each.getSelected()); result.add(entry); } return result; }
@Override public void migrate(JCas source, JCas target) { target.setDocumentText(source.getDocumentText()); FeatureStructureCopyingQueue featureStructureCopyingQueue = new FeatureStructureCopyingQueue( source.getCas(), target.getCas()); FSIterator<FeatureStructure> allFs = source.getIndexRepository() .getAllIndexedFS(source.getCasType(TOP.type)); while (allFs.hasNext()) { featureStructureCopyingQueue.enqueue(allFs.next()); } featureStructureCopyingQueue.run(); } }