public Set<AnnotationFS> getBeginAnchors(Type type) { Set<AnnotationFS> set = beginMap.get(type); if (lowMemoryProfile) { Set<AnnotationFS> result = new HashSet<AnnotationFS>(); if (set != null) { result.addAll(set); } List<Type> subsumedTypes = getCAS().getTypeSystem().getProperlySubsumedTypes(type); for (Type each : subsumedTypes) { Set<AnnotationFS> c = beginMap.get(each); if (c != null) { result.addAll(c); } } return result; } else { if(set == null) { return Collections.emptySet(); } else { return set; } } }
@Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (newInput instanceof TypeSystem) { TypeSystem ts = (TypeSystem) newInput; List<Type> annotationTypeList = ts.getProperlySubsumedTypes(ts.getType(CAS.TYPE_NAME_ANNOTATION)); annotationTypeList.add(ts.getType(CAS.TYPE_NAME_ANNOTATION)); annotationTypes = new AnnotationTypeNode[annotationTypeList.size()]; for (int i = 0; i < annotationTypeList.size(); i++) { annotationTypes[i] = new AnnotationTypeNode(editor, annotationTypeList.get(i)); } } else { annotationTypes = null; } }
public Set<AnnotationFS> getEndAnchors(Type type) { Set<AnnotationFS> set = endMap.get(type); if (lowMemoryProfile) { Set<AnnotationFS> result = new HashSet<AnnotationFS>(set); if (set != null) { result.addAll(set); } List<Type> subsumedTypes = getCAS().getTypeSystem().getProperlySubsumedTypes(type); for (Type each : subsumedTypes) { Set<AnnotationFS> c = endMap.get(each); if (c != null) { result.addAll(c); } } return result; } else { if(set == null) { return Collections.emptySet(); } else { return set; } } }
/** * 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); } } }
private FSMatchConstraint createCurrentConstraint(boolean windowConstraint) { Set<Type> filterTypes = new HashSet<Type>(); filterTypes.addAll(defaultFilterTypes); filterTypes.addAll(currentFilterTypes); filterTypes.removeAll(currentRetainTypes); for (Type type : currentRetainTypes) { if (type != null) { List<Type> subsumedTypes = cas.getTypeSystem().getProperlySubsumedTypes(type); filterTypes.removeAll(subsumedTypes); } } currentHiddenTypes = filterTypes; FSMatchConstraint typeConstraint = createTypeConstraint(filterTypes); FSMatchConstraint constraint = new NotConstraint(typeConstraint); if (additionalWindow != null && windowConstraint) { constraint = cf.and(additionalWindow, constraint); } return constraint; }
/** * Sets the input. * * @param superType the super type * @param typeSystem the type system * @param filterTypes the filter types */ public void setInput(Type superType, TypeSystem typeSystem, Collection<Type> filterTypes) { this.typeSystem = typeSystem; typeNameList = new LinkedList<String>(); typeNameList.add(superType.getName()); for (Type type : typeSystem.getProperlySubsumedTypes(superType)) { if (!filterTypes.contains(type)) { typeNameList.add(type.getName()); } } typeCombo.setItems(typeNameList.toArray(new String[typeNameList.size()])); // select the super type, its the first element (and must be there) typeCombo.select(0); }
public boolean beginsWith(Type type) { if (beginMap.containsKey(type)) { return true; } if (lowMemoryProfile) { List<Type> subsumedTypes = getCAS().getTypeSystem().getProperlySubsumedTypes(type); for (Type each : subsumedTypes) { if (beginsWith(each)) { return true; } } } return false; }
public boolean endsWith(Type type) { if (endMap.containsKey(type)) { return true; } if (lowMemoryProfile) { List<Type> subsumedTypes = getCAS().getTypeSystem().getProperlySubsumedTypes(type); for (Type each : subsumedTypes) { if (endsWith(each)) { return true; } } } return false; }
private void resolveType(String mention, RutaBlock rootBlock, TypeSystem typeSystem) { Type type = rootBlock.getEnvironment().getType(mention); if (type != null) { usedTypes.add(type.getName()); usedTypesWithSubTypes.add(type.getName()); List<Type> properlySubsumedTypes = typeSystem.getProperlySubsumedTypes(type); for (Type subsumedType : properlySubsumedTypes) { usedTypesWithSubTypes.add(subsumedType.getName()); } } }
/** * Gets the types. * * @return the types */ private Type[] getTypes() { TypeSystem typeSystem = editor.getDocument().getCAS().getTypeSystem(); List<Type> types = typeSystem.getProperlySubsumedTypes(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION)); types.add(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION)); return types.toArray(new Type[types.size()]); }
public boolean isPartOf(Type type) { Integer count = partOf.get(type.getName()); if (count != null && count > 0) { return true; } if (lowMemoryProfile) { List<Type> subsumedTypes = getCAS().getTypeSystem().getProperlySubsumedTypes(type); for (Type each : subsumedTypes) { Integer parentCount = partOf.get(each.getName()); if (parentCount != null && parentCount > 0) { return true; } } } return false; }
@SuppressWarnings("unchecked") public Collection<AnnotationFS> getBeginAnchors(Type type) { int code = ((TypeImpl) type).getCode(); Collection<AnnotationFS> set = (Collection<AnnotationFS>) beginMap[code]; if (lowMemoryProfile) { Collection<AnnotationFS> result = new ArrayList<AnnotationFS>(); if (set != null) { result.addAll(set); } List<Type> subsumedTypes = getCAS().getTypeSystem().getProperlySubsumedTypes(type); for (Type each : subsumedTypes) { int parentCode = ((TypeImpl) each).getCode(); Collection<?> c = beginMap[parentCode]; if (c != null) { result.addAll((Collection<? extends AnnotationFS>) c); } } return result; } else { if (set == null) { return Collections.emptySet(); } else { return set; } } }
@SuppressWarnings("unchecked") public Collection<AnnotationFS> getEndAnchors(Type type) { int code = ((TypeImpl) type).getCode(); Collection<AnnotationFS> set = (Collection<AnnotationFS>) endMap[code]; if (lowMemoryProfile) { Collection<AnnotationFS> result = new ArrayList<AnnotationFS>(); if (set != null) { result.addAll(set); } List<Type> subsumedTypes = getCAS().getTypeSystem().getProperlySubsumedTypes(type); for (Type each : subsumedTypes) { int parentCode = ((TypeImpl) each).getCode(); Collection<?> c = endMap[parentCode]; if (c != null) { result.addAll((Collection<? extends AnnotationFS>) c); } } return result; } else { if (set == null) { return Collections.emptySet(); } else { return set; } } }
public boolean endsWith(Type type) { int code = ((TypeImpl) type).getCode(); Collection<?> set = endMap[code]; boolean endswith = set != null && !set.isEmpty(); if (endswith) { return true; } if (lowMemoryProfile) { List<Type> subsumedTypes = getCAS().getTypeSystem().getProperlySubsumedTypes(type); for (Type each : subsumedTypes) { if (endsWith(each)) { return true; } } } return false; }
public boolean beginsWith(Type type) { int code = ((TypeImpl) type).getCode(); Collection<?> set = beginMap[code]; boolean beginsWith = set != null && !set.isEmpty(); if (beginsWith) { return true; } if (lowMemoryProfile) { List<Type> subsumedTypes = getCAS().getTypeSystem().getProperlySubsumedTypes(type); for (Type each : subsumedTypes) { if (beginsWith(each)) { return true; } } } return false; }
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 boolean isPartOf(Type type) { int code = ((TypeImpl) type).getCode(); int count = partOf[code]; if (count > 0) { return true; } if (lowMemoryProfile) { List<Type> subsumedTypes = getCAS().getTypeSystem().getProperlySubsumedTypes(type); for (Type each : subsumedTypes) { int code2 = ((TypeImpl) each).getCode(); int count2 = partOf[code2]; if (count2 > 0) { return true; } } } return false; }
public Collection<AnnotationFS> getAnnotationsBefore(TextMarkerRuleElement ruleElement, AnnotationFS annotation, TextMarkerStream stream, TextMarkerBlock parent) { TextMarkerBasic firstBasic = stream.getBeginAnchor(annotation.getBegin()); if (firstBasic == null) { return Collections.emptyList(); } stream.moveTo(firstBasic); stream.moveToPrevious(); if (stream.isValid()) { TextMarkerBasic nextBasic = (TextMarkerBasic) stream.get(); List<Type> reTypes = getTypes(parent, stream); Collection<AnnotationFS> anchors = new TreeSet<AnnotationFS>(comparator); for (Type eachMatchType : reTypes) { List<Type> types = stream.getCas().getTypeSystem().getProperlySubsumedTypes(eachMatchType); types.add(eachMatchType); for (Type eachType : types) { Collection<AnnotationFS> endAnchors = nextBasic.getEndAnchors(eachType); if (endAnchors != null) { for (AnnotationFS afs : endAnchors) { if (afs.getBegin() >= stream.getDocumentAnnotation().getBegin()) { anchors.add(afs); } } } } } return anchors; } return Collections.emptyList(); }
List<Type> types = typeSystem.getProperlySubsumedTypes( typeSystem.getType(CAS.TYPE_NAME_ANNOTATION));
public void initializeTypes(CAS cas) { this.cas = cas; Type topType = null; try { topType = cas.getJCas().getCasType(TOP.type); if (topType != null) { List<Type> list = cas.getTypeSystem().getProperlySubsumedTypes(topType); for (Type type : list) { addType(type); } } Type documentType = cas.getJCas().getCasType(DocumentAnnotation.type); addType("Document", documentType); Type annotationType = cas.getJCas().getCasType(org.apache.uima.jcas.tcas.Annotation.type); addType("Annotation", annotationType); } catch (CASException e) { } }