Package org.apache.uima.cas

Examples of org.apache.uima.cas.Type


      Ruta.apply(cas, script);
    } catch (Exception e) {
      e.printStackTrace();
    }
   
    Type t = null;
    AnnotationIndex<AnnotationFS> ai = null;
    FSIterator<AnnotationFS> iterator = null;

    t = RutaTestUtils.getTestType(cas, 4);
    ai = cas.getAnnotationIndex(t);
View Full Code Here


      cas = RutaTestUtils.getCAS(document);
      Ruta.apply(cas, script);
    } catch (Exception e) {
    }

    Type t = null;
    AnnotationIndex<AnnotationFS> ai = null;
    FSIterator<AnnotationFS> iterator = null;


   
View Full Code Here

          }
          setAnnotationMode(annotationMode);
          Iterator<Type> typeIterator = casEditor.getDocument().getCAS().getTypeSystem()
                  .getTypeIterator();
          while (typeIterator.hasNext()) {
            Type type = (Type) typeIterator.next();
            boolean contains = selectedTypes.contains(type.getName());
            casEditor.setShownAnnotationType(type, contains);
          }
          currentDocument = newDoc;
          treeView.getControl().setFocus();
        }
View Full Code Here

        }
        AnnotationCheckTreeNode[] annotationNodes = each.getChildren();
        for (AnnotationCheckTreeNode eachAN : annotationNodes) {
          CheckAnnotation ca = (CheckAnnotation) eachAN.getElement();
          if (ca.checked && ca.keep) {
            Type type = cas.getTypeSystem().getType(ca.type);
            if (type != null) {
              AnnotationFS createAnnotation = cas.createAnnotation(type, ca.begin, ca.end);
              cas.addFsToIndexes(createAnnotation);
            }
          }
View Full Code Here

  }

  public void setAnnotationMode(String typeString) {
    this.annotationMode = typeString;
    if (casEditor != null && casEditor.getDocument() != null && typeString != null) {
      Type type = casEditor.getDocument().getCAS().getTypeSystem().getType(typeString);
      casEditor.setAnnotationMode(type);
    }
  }
View Full Code Here

   *          must contain TP, FP, FN annotations
   */
  public void calculateEvaluatData(TestCasData data, CAS resultCas) {
    data.setEvaluationStatus(true);
    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();

    data.setTruePositiveCount(truePositiveCount);
    data.setFalsePositiveCount(falsePositiveCount);
    data.setFalseNegativeCount(falseNegativeCount);

    HashMap<String, TypeEvalData> map = new HashMap<String, TypeEvalData>();

    AnnotationIndex<AnnotationFS> index = resultCas.getAnnotationIndex(truePositiveType);

    FSIterator<AnnotationFS> iter = index.iterator();

    while (iter.isValid()) {
      EvalAnnotation a = (EvalAnnotation) iter.next();
      Annotation original = a.getOriginal();
      Type originalType = original.getType();

      if (map.containsKey(originalType.getName())) {
        TypeEvalData element = (TypeEvalData) map.get(originalType.getName());
        int oldCount = element.getTruePositives();
        element.setTruePositives(oldCount + 1);
      } else {
        TypeEvalData newData = new TypeEvalData(originalType.getName(), 1, 0, 0);
        map.put(originalType.getName(), newData);
      }
    }

    index = resultCas.getAnnotationIndex(falsePositiveType);
    iter = index.iterator();

    while (iter.isValid()) {
      EvalAnnotation a = (EvalAnnotation) iter.next();
      Annotation original = a.getOriginal();
      Type originalType = original.getType();

      if (map.containsKey(originalType.getName())) {
        TypeEvalData element = (TypeEvalData) map.get(originalType.getName());
        int oldCount = element.getFalsePositives();
        element.setFalsePositives(oldCount + 1);
      } else {
        TypeEvalData newData = new TypeEvalData(originalType.getName(), 0, 1, 0);
        map.put(originalType.getName(), newData);
      }
    }

    index = resultCas.getAnnotationIndex(falseNegativeType);
    iter = index.iterator();

    while (iter.isValid()) {
      EvalAnnotation a = (EvalAnnotation) iter.next();
      Annotation original = a.getOriginal();
      Type originalType = original.getType();

      if (map.containsKey(originalType.getName())) {
        TypeEvalData element = (TypeEvalData) map.get(originalType.getName());
        int oldCount = element.getFalseNegatives();
        element.setFalseNegatives(oldCount + 1);
      } else {
        TypeEvalData newData = new TypeEvalData(originalType.getName(), 0, 0, 1);
        map.put(originalType.getName(), newData);
      }
    }

    data.setTypeEvalData(map);
  }
View Full Code Here

        cas.setDocumentText(documentText);
      } else {
        List<AnnotationFS> toRemove = new LinkedList<AnnotationFS>();
        AnnotationIndex<AnnotationFS> annotationIndex = cas.getAnnotationIndex();
        for (AnnotationFS annotationFS : annotationIndex) {
          Type type = annotationFS.getType();
          String typeName = type.getName();
          if (includedTypes.contains(typeName) || !excludedTypes.contains(typeName)) {
            toRemove.add(annotationFS);
          }
        }
        System.out.println();
View Full Code Here

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    List<List<RuleElementMatch>> list = match.getMatchInfo(element);
    CAS cas = stream.getCas();
    Type t = type.getType(element.getParent());
    for (List<RuleElementMatch> eachList : list) {
      for (RuleElementMatch each : eachList) {
        List<AnnotationFS> matched = each.getTextsMatched();
        for (AnnotationFS annotationFS : matched) {
          FeatureStructure createFS = cas.createFS(t);
View Full Code Here

  }

  private void copyFeatures(AnnotationFS oldFS, FeatureStructure newFS, CAS cas) {
    List<?> features = oldFS.getType().getFeatures();
    Type newType = newFS.getType();
    for (Object object : features) {
      Feature feature = (Feature) object;
      String shortName = feature.getShortName();
      Feature newFeature = newType.getFeatureByBaseName(shortName);
      if (newFeature != null) {
        if (feature.getRange().isPrimitive()) {
          String value = oldFS.getFeatureValueAsString(newFeature);
          newFS.setFeatureValueFromString(newFeature, value);
        } else {
View Full Code Here

  }

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    TypeExpression typeExpr = expr.getTypeExpr();
    Type type = typeExpr.getType(element.getParent());
    List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotationsOf(element);
    Collection<AnnotationFS> annotations = new TreeSet<AnnotationFS>(comp);
    for (AnnotationFS annotation : matchedAnnotations) {
      annotations.addAll(getAnnotations(annotation, type, expr, stream));
    }
View Full Code Here

TOP

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

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.