/** * Imports all types that are known to a type system. * * @param ts * Type system to import. * @throws CASException */ private void importAllTypes(TypeSystem ts) throws CASException { Type topType = ts.getTopType(); if (topType != null) { List<Type> list = ts.getProperlySubsumedTypes(topType); for (Type type : list) { addType(type); } } }
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 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 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<>( Comparator.comparingInt(llcas::ll_getFSRef)); 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; } }
/** * Update type tree. */ private void updateTypeTree() { if (this.ts == null) { return; } DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) this.typeTree.getModel().getRoot(); rootNode.removeAllChildren(); // UIMA-2565 - Clash btw. cas.Type and Window.Type on JDK 7 org.apache.uima.cas.Type top = this.ts.getTopType(); rootNode.setUserObject(top); List<org.apache.uima.cas.Type> types = this.ts.getDirectSubtypes(top); for (int i = 0; i < types.size(); i++) { rootNode.add(createTypeTree(types.get(i))); } DefaultTreeModel model = (DefaultTreeModel) this.typeTree.getModel(); // 1.3 compatability hack. // TreeModelListener[] listeners = model.getTreeModelListeners(); TreeModelListener[] listeners = getTreeModelListeners(model); // System.out.println("Number of tree model listeners: " + // listeners.length); Object[] path = new Object[1]; path[0] = rootNode; TreeModelEvent event = new TreeModelEvent(rootNode, path); for (int i = 0; i < listeners.length; i++) { listeners[i].treeStructureChanged(event); } }
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 copyDownSuperGenerators(Map<String, LoadedJCasType<?>> jcasTypes, FSGenerator<?>[] fsGenerators) { final TypeSystem ts = casImpl.getTypeSystem(); Type topType = ts.getTopType(); Type superType = null; while (typeIt.hasNext()) {
if (!aTS.getTopType().equals(aTS.getParent(linkType))) { return false;
if (!aTS.getTopType().equals(aTS.getParent(linkType))) { return false;
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; } }
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; } }
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; }