Package org.apache.uima.cas

Examples of org.apache.uima.cas.TypeSystem


   * @param feature
   * @return the primitive value as object
   */
  public static Object getPrimitive(FeatureStructure structure, Feature feature) {
   
    TypeSystem ts = structure.getCAS().getTypeSystem();
   
    Class<?> primitiveClass = getPrimitiveClass(ts, feature);
   
    Object result;

View Full Code Here


      initialize(eeUimaEngine, appCtx);
      waitUntilInitialized();
      //  Check if the type system returned from the service contains
      //  expected types
      CAS cas = eeUimaEngine.getCAS();
      TypeSystem ts = cas.getTypeSystem();
      //  "example.EmailsAddress" type was 'contributed' by the Flow Controller
      if ( ts.getType("example.EmailAddress") == null ) {
        fail("Incomplete Type system. Expected Type 'example.EmailAddress' missing from the CAS type system");
      } else if ( ts.getType("example.GovernmentOfficial") == null) {
        fail("Incomplete Type system. Expected Type 'example.GovernmentOfficial' missing from the CAS type system");
      } else if ( ts.getType("example.Name") == null) {
        fail("Incomplete Type system. Expected Type 'example.Name' missing from the CAS type system");
      } else if ( ts.getType("example.PersonTitle") == null) {
        fail("Incomplete Type system. Expected Type 'example.PersonTitle' missing from the CAS type system");
      } else if ( ts.getType("example.PersonTitleKind") == null) {
        fail("Incomplete Type system. Expected Type 'example.PersonTitleKind' missing from the CAS type system");
      } else if ( ts.getType("org.apache.uima.examples.tokenizer.Sentence") == null) {
        fail("Incomplete Type system. Expected Type 'org.apache.uima.examples.tokenizer.Sentence' missing from the CAS type system");
      } else if ( ts.getType("org.apache.uima.examples.tokenizer.Token") == null) {
        fail("Incomplete Type system. Expected Type 'org.apache.uima.examples.tokenizer.Token' missing from the CAS type system");
      }
     
    } catch (ResourceInitializationException e) {
        fail("Initialization Exception");
View Full Code Here

  public void removeHandlerListener(IHandlerListener arg0) {

  }

  private double calculateF1(CAS resultCas) {
    TypeSystem ts = resultCas.getTypeSystem();

    Type falsePositiveType = ts.getType(ICasEvaluator.FALSE_POSITIVE);
    Type falseNegativeType = ts.getType(ICasEvaluator.FALSE_NEGATIVE);
    Type truePositiveType = ts.getType(ICasEvaluator.TRUE_POSITIVE);

    int falsePositiveCount = resultCas.getAnnotationIndex(falsePositiveType).size();
    int falseNegativeCount = resultCas.getAnnotationIndex(falseNegativeType).size();
    int truePositiveCount = resultCas.getAnnotationIndex(truePositiveType).size();
View Full Code Here

        }
        AnnotationCheckTreeNode[] annotationNodes = each.getChildren();
        for (AnnotationCheckTreeNode eachAN : annotationNodes) {
          CheckAnnotation ca = (CheckAnnotation) eachAN.getElement();
          if (ca.checked && ca.keep) {
            TypeSystem ts = casEditor.getDocument().getCAS().getTypeSystem();
            Type type = ts.getType(ca.getTypeName());
            if (type != null) {
              AnnotationFS annotFS = ca.toAnnotationFS(cas, type);
              if (eachAN.hasChildren()) {
                FeatureCheckTreeNode[] featureNodes = (FeatureCheckTreeNode[]) eachAN.getChildren();
                for (FeatureCheckTreeNode featureNode : featureNodes) {
View Full Code Here

    Type annotationType = test.getAnnotationType();
    Type stringType = run.getTypeSystem().getType(UIMAConstants.TYPE_STRING);
    Type basicType = run.getTypeSystem().getType(RutaEngine.BASIC_TYPE);
    List<Type> allTypes = test.getTypeSystem().getProperlySubsumedTypes(annotationType);
    List<Type> types = new ArrayList<Type>();
    TypeSystem typeSystem = test.getTypeSystem();
    for (Type eachType : allTypes) {
      if (!excludedTypes.contains(eachType.getName())) {
        List<Feature> features = eachType.getFeatures();
        for (Feature f : features) {
          Type range = f.getRange();
          if (typeSystem.subsumes(annotationType, range) || typeSystem.subsumes(stringType, range)) {
            if (!eachType.getName().startsWith("org.apache.uima.ruta.type")
                    && !typeSystem.subsumes(basicType, eachType)) {
              types.add(eachType);
              break;
            }
          }
        }
View Full Code Here

    if (withFeatures) {

      CAS testCas = fs.getCAS();

      CAS runCas = newFS.getCAS();
      TypeSystem testTS = testCas.getTypeSystem();
      TypeSystem runTS = runCas.getTypeSystem();
      Type annotationType = testCas.getAnnotationType();
      List<Feature> features = fs.getType().getFeatures();
      for (Feature feature : features) {
        Type range = feature.getRange();
        if (testTS.subsumes(annotationType, range)) {
          FeatureStructure valueTest = fs.getFeatureValue(feature);
          if (valueTest instanceof AnnotationFS) {
            AnnotationFS a1 = (AnnotationFS) valueTest;
            Feature feature2 = newFS.getType().getFeatureByBaseName(feature.getShortName());
            if (feature2 != null) {
              Type range2 = runTS.getType(range.getName());
              AnnotationFS createAnnotation = runCas.createAnnotation(range2, a1.getBegin(),
                      a1.getEnd());
              newFS.setFeatureValue(feature2, createAnnotation);
            }
          }
View Full Code Here

    }

  }

  private Collection<FeatureStructure> getFeatureStructures(List<Type> types, CAS cas) {
    TypeSystem typeSystem = cas.getTypeSystem();
    Type annotationType = cas.getAnnotationType();
    // Type annotationBaseType = typeSystem.getType("uima.cas.AnnotationBase");
    Collection<FeatureStructure> result = new HashSet<FeatureStructure>();
    for (Type type : types) {
      // if ((type != null) && !typeSystem.subsumes(cas.getAnnotationType(), type) &&
      // !typeSystem.subsumes(annotationBaseType, type)
      if (type != null) {
        FSIterator<FeatureStructure> iterator = cas.getIndexRepository().getAllIndexedFS(type);
        try {
          iterator = cas.getView("_InitialView").getJCas().getIndexRepository()
                  .getAllIndexedFS(type);
        } catch (CASException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        // FSIterator<FeatureStructure> iterator=cas.getIndexRepository().getAllIndexedFS(type);;
        while (iterator.isValid()) { // hasNext()
          FeatureStructure fs = iterator.get();
          List<Feature> features = fs.getType().getFeatures();
          for (Feature feature : features) {
            Type range = feature.getRange();
            if (typeSystem.subsumes(annotationType, range)
                    || UIMAConstants.TYPE_STRING.equals(range.getName())) {
              result.add(fs);
              break;
            }
          }
View Full Code Here

      }
    }

    CAS cas = a1.getCAS();

    TypeSystem typeSystem = cas.getTypeSystem();

    Type annotationType = cas.getAnnotationType();

    List<Feature> features1 = type1.getFeatures();

    boolean result = true;

    boolean allEmpty1 = true;

    boolean allEmpty2 = true;

    for (Feature eachFeature1 : features1) {

      Type range = eachFeature1.getRange();

      if (typeSystem.subsumes(annotationType, range)) {

        String name = eachFeature1.getShortName();

        Feature eachFeature2 = type2.getFeatureByBaseName(name);
View Full Code Here

public abstract class AbstractCasEvaluator implements ICasEvaluator {

  protected List<AnnotationFS> getAnnotations(List<Type> types, CAS cas, boolean includeSubtypes) {
    List<AnnotationFS> result = new ArrayList<AnnotationFS>();
    TypeSystem typeSystem = cas.getTypeSystem();
    AnnotationIndex<AnnotationFS> annotationIndex = cas.getAnnotationIndex();
    for (AnnotationFS each : annotationIndex) {
      Type type = each.getType();
      for (Type eachType : types) {
        if (includeSubtypes && typeSystem.subsumes(eachType, type)) {
          result.add(each);
          break;
        } else if (eachType.getName().equals(type.getName())) {
          result.add(each);
          break;
View Full Code Here

    }
  }

  private Type getRandomType(RutaStream stream) {
    Type annotationType = stream.getCas().getTypeSystem().getType("org.apache.uima.ruta.type.TokenSeed");
    TypeSystem typeSystem = stream.getCas().getTypeSystem();
    List<Type> subsumedTypes = typeSystem.getProperlySubsumedTypes(annotationType);
    Random r = new Random();
    int nextInt = r.nextInt(subsumedTypes.size());
    return subsumedTypes.get(nextInt);
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.cas.TypeSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.