/** * Creates the type tree. * * @param type the type * @return the default mutable tree node */ private DefaultMutableTreeNode createTypeTree(org.apache.uima.cas.Type type) { DefaultMutableTreeNode node = new DefaultMutableTreeNode(type); // UIMA-2565 - Clash btw. cas.Type and Window.Type on JDK 7 // also on method parameter "type" List<org.apache.uima.cas.Type> types = this.ts.getDirectSubtypes(type); final int max = types.size(); for (int i = 0; i < max; i++) { DefaultMutableTreeNode child = createTypeTree(types.get(i)); node.add(child); } return node; }
private static final void getFeatureDefiningSubtypes(Type type, String fName, List<Type> types) { TypeSystem ts = ((TypeImpl) type).getTypeSystem(); List<?> subtypes = ts.getDirectSubtypes(type); for (int i = 0; i < subtypes.size(); i++) { Type subtype = (Type) subtypes.get(i); if (subtype.getFeatureByBaseName(fName) != null) { types.add((Type) subtypes.get(i)); } else { getFeatureDefiningSubtypes(subtype, fName, types); } } }
private Map<String, Collection<?>> createTaxonomyTreeForType(String typeName) { Map<String, Collection<?>> treeForType = new HashMap<>(); Type type = getType(typeName); List<Type> subTypes = typeSystem.getDirectSubtypes(type); List<Object> typeValues = new ArrayList<>(); treeForType.put(type.getShortName(), typeValues); for (Type subType : subTypes) { typeValues.add(createTaxonomyTreeForType(subType.getName())); } return treeForType; }
/** * Adds the children. * * @param node the node * @param type the type * @param ts the ts */ private static void addChildren(DefaultMutableTreeNode node, org.apache.uima.cas.Type type, TypeSystem ts) { // UIMA-2565 - Clash btw. cas.Type and Window.Type on JDK 7 List<org.apache.uima.cas.Type> dtrs = ts.getDirectSubtypes(type); DefaultMutableTreeNode dtrNode; org.apache.uima.cas.Type dtrType; for (int i = 0; i < dtrs.size(); i++) { dtrType = dtrs.get(i); dtrNode = new DefaultMutableTreeNode(dtrType.getName()); node.add(dtrNode); addChildren(dtrNode, dtrType, ts); } } }
private Map<String, Collection<?>> createTaxonomyTreeForType(String typeName) { Map<String, Collection<?>> treeForType = new HashMap<>(); Type type = getType(typeName); List<Type> subTypes = typeSystem.getDirectSubtypes(type); List<Object> typeValues = new ArrayList<>(); treeForType.put(type.getShortName(), typeValues); for (Type subType : subTypes) { typeValues.add(createTaxonomyTreeForType(subType.getName())); } return treeForType; }
private boolean isElevatedType(TypeSystem aTS, Type aType) { // Elevated types do not contribute any new features if (aType.getFeatures().stream().anyMatch(f -> f.getDomain().equals(aType))) { return false; } // Elevated types have only sub-types which are also elevated types if (aTS.getDirectSubtypes(aType).stream().anyMatch(t -> !isElevatedType(aTS, t))) { return false; } // Elevated types do not inherit from Annotation if (aTS.getParent(aType).equals(aTS.getType(CAS.TYPE_NAME_ANNOTATION))) { return false; } // Hm, ok, so this looks like an elevated type return true; }
private boolean isElevatedType(TypeSystem aTS, Type aType) { // Elevated types do not contribute any new features if (aType.getFeatures().stream().anyMatch(f -> f.getDomain().equals(aType))) { return false; } // Elevated types have only sub-types which are also elevated types if (aTS.getDirectSubtypes(aType).stream().anyMatch(t -> !isElevatedType(aTS, t))) { return false; } // Elevated types do not inherit from Annotation if (aTS.getParent(aType).equals(aTS.getType(CAS.TYPE_NAME_ANNOTATION))) { return false; } // Hm, ok, so this looks like an elevated type return true; }
private int getEntityChildrenCount() throws CASRuntimeException, UIMAException { Type type = typeSystem.getType(Entity.class.getName()); return typeSystem.getDirectSubtypes(type).size(); } }
/** * Creates the type tree. * * @param type the type * @param ts the ts * @param label the label * @param ir the ir * @return the default mutable tree node */ private DefaultMutableTreeNode createTypeTree(org.apache.uima.cas.Type type, TypeSystem ts, String label, FSIndexRepository ir) { int size = ir.getIndex(label, type).size(); TypeTreeNode typeNode = new TypeTreeNode(type, label, size); DefaultMutableTreeNode node = new DefaultMutableTreeNode(typeNode); // UIMA-2565 - Clash btw. cas.Type and Window.Type on JDK 7 // also on method parameter "type" List<org.apache.uima.cas.Type> types = ts.getDirectSubtypes(type); final int max = types.size(); for (int i = 0; i < max; i++) { if (ir.getIndex(label, types.get(i)) == null) { continue; } DefaultMutableTreeNode child = createTypeTree(types.get(i), ts, label, ir); node.add(child); } return node; }
/** * 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); } }
boolean isParentIncluded) { List<Type> childs = mTypeSystem.getDirectSubtypes(parentType);
private OntClass addType(OntModel ontModel, OntClass parent, Type type) { TypeDescription description = descriptions.getType(type.getName()); OntClass ontClass = ontModel.createClass(namespace + type.getShortName()); String comment = description.getDescription(); if (comment != null) { ontClass.addComment(comment, EN); } HashSet<FeatureDescription> features = new HashSet<>(); if (parent != null) { parent.addSubClass(ontClass); features.addAll(Arrays.asList(description.getFeatures())); } else { for (Feature feature : type.getFeatures()) { TypeDescription typeDescription = descriptions.getType(feature.getDomain().getName()); if (typeDescription != null) { features.addAll(Arrays.asList(typeDescription.getFeatures())); } } } for (FeatureDescription feature : features) { if (!ignoreProperties.contains(feature.getName())) { addFeature(ontModel, ontClass, feature); } } for (Type child : typeSystem.getDirectSubtypes(type)) { addType(ontModel, ontClass, child); } return ontClass; }
private OntClass addType(OntModel ontModel, OntClass parent, Type type) { TypeDescription description = descriptions.getType(type.getName()); OntClass ontClass = ontModel.createClass(namespace + type.getShortName()); String comment = description.getDescription(); if (comment != null) { ontClass.addComment(comment, EN); } HashSet<FeatureDescription> features = new HashSet<>(); if (parent != null) { parent.addSubClass(ontClass); features.addAll(Arrays.asList(description.getFeatures())); } else { for (Feature feature : type.getFeatures()) { TypeDescription typeDescription = descriptions.getType(feature.getDomain().getName()); if (typeDescription != null) { features.addAll(Arrays.asList(typeDescription.getFeatures())); } } } for (FeatureDescription feature : features) { if (!ignoreProperties.contains(feature.getName())) { addFeature(ontModel, ontClass, feature); } } for (Type child : typeSystem.getDirectSubtypes(type)) { addType(ontModel, ontClass, child); } return ontClass; }
for (Type type : aTypeSystem.getDirectSubtypes(annotationType)) { if (aTypeSystem.subsumes(documentAnnotationType, type)) { continue; for (Type type : aTypeSystem.getDirectSubtypes(topType)) { Feature firstFeat = type.getFeatureByBaseName(CHAIN_FIRST_FEAT); if (firstFeat != null && chainLinkTypes.contains(firstFeat.getRange())) {
for (Type type : aTypeSystem.getDirectSubtypes(annotationType)) { if (aTypeSystem.subsumes(documentAnnotationType, type)) { continue; for (Type type : aTypeSystem.getDirectSubtypes(topType)) { Feature firstFeat = type.getFeatureByBaseName(CHAIN_FIRST_FEAT); if (firstFeat != null && chainLinkTypes.contains(firstFeat.getRange())) {