Java Code Examples for org.apache.uima.cas.TypeSystem#getProperlySubsumedTypes()

The following examples show how to use org.apache.uima.cas.TypeSystem#getProperlySubsumedTypes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationStyleViewPage.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
@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;
  }
  
}
 
Example 2
Source File: TypeCombo.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * 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<>();

  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);
}
 
Example 3
Source File: TypeGroupedContentProvider.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
 public void changed() {
	nameAnnotationTypeNodeMap.clear();
	
	TypeSystem typeSystem = mInputDocument.getCAS().getTypeSystem();
	
	List<Type> types = typeSystem.getProperlySubsumedTypes(
			typeSystem.getType(CAS.TYPE_NAME_ANNOTATION));
	
	types.add(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION));
	
	for (Type type : types) {
		
		AnnotationTypeTreeNode typeNode = new AnnotationTypeTreeNode(type);
		
		nameAnnotationTypeNodeMap.put(type.getName(), typeNode);
		
		CAS cas = mInputDocument.getCAS();
		
		AnnotationIndex<AnnotationFS> index = cas.getAnnotationIndex(type);

		for (AnnotationFS annotation : index) {
			if (annotation.getType().equals(type)) {
				typeNode.add(new AnnotationTreeNode(mInputDocument, annotation));
			}
		}
	}

     Display.getDefault().syncExec(new Runnable() {
       @Override
       public void run() {
       	viewer.refresh();
       }
     });
}
 
Example 4
Source File: TypeSection.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
/**
 * CALL THIS FN after removing and remerging. Assuming the localTd is removed, it may result in
 * the mergedTd having fewer features. Compute the features that would be removed. Do it not just
 * for this type, but for all subtypes of this type. NOTE: if mergeTd is null, it means the type
 * is removed completely (no shadowing of built-in or imported types), so no special feature
 * removal is needed.
 *
 * @param localTd the local td
 * @param mergedTd          The "remerged" value of the type.
 * @return array of string names of features to be removed
 */

private TypeFeature[] computeFeaturesToRemove(TypeDescription localTd, TypeDescription mergedTd) {
  if (null == mergedTd)
    return typeFeature0;
  FeatureDescription[] locallyDefinedFeatures = localTd.getFeatures();
  if (null == locallyDefinedFeatures || locallyDefinedFeatures.length == 0)
    return typeFeature0;

  FeatureDescription[] remainingFeatures = mergedTd.getFeatures();
  ArrayList deletedFeatures = new ArrayList();

  outer: for (int i = 0; i < locallyDefinedFeatures.length; i++) {
    String fname = locallyDefinedFeatures[i].getName();
    if (null != remainingFeatures)
      for (int j = 0; j < remainingFeatures.length; j++) {
        if (fname.equals(remainingFeatures[j].getName()))
          continue outer;
      }
    deletedFeatures.add(fname);
  }

  // have list of features really disappearing (not kept present by imports or built-ins)
  // return all types/features of these for types which are subtypes of the passed-in type

  CAS tcas = editor.getCurrentView();
  TypeSystem typeSystem = tcas.getTypeSystem();
  Type thisType = typeSystem.getType(localTd.getName());
  List subsumedTypesList = typeSystem.getProperlySubsumedTypes(thisType);
  subsumedTypesList.add(thisType);
  Type[] subsumedTypes = (Type[]) subsumedTypesList.toArray(new Type[0]);

  String[] featNameArray = (String[]) deletedFeatures.toArray(new String[deletedFeatures.size()]);
  ArrayList result = new ArrayList();
  for (int i = 0; i < subsumedTypes.length; i++) {
    Type t = subsumedTypes[i];
    for (int j = 0; j < featNameArray.length; j++) {
      if (null != t.getFeatureByBaseName(featNameArray[j]))
        result.add(new TypeFeature(t.getName(), featNameArray[j]));
    }
  }
  return (TypeFeature[]) result.toArray(typeFeature0);
}
 
Example 5
Source File: QuickTypeSelectionDialog.java    From uima-uimaj with Apache License 2.0 3 votes vote down vote up
/**
 * 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()]);
}