Package org.apache.uima.cas

Examples of org.apache.uima.cas.TypeSystem


    // check if all passed slot types are present:
    CAS someCas = getTestCAS();
    if (someCas == null) {
      return false;
    }
    TypeSystem ts = someCas.getTypeSystem();
    // GlobalCASSource.releaseCAS(someCas);
    boolean result = true;
    List<String> missingTypes = new ArrayList<String>();
    for (String s : slotNames) {
      if (ts.getType(s) == null) {
        missingTypes.add(s);
        result = false;
      }
    }
    String missingString = "";
View Full Code Here


  public TextRulerWordConstraint(TextRulerAnnotation tokenAnnotation) {
    super();
    this.tokenAnnotation = tokenAnnotation;
    if (AUTO_REGEXP) {
      CAS cas = tokenAnnotation.getDocument().getCAS();
      TypeSystem ts = cas.getTypeSystem();
      Type wType = ts.getType(TextRulerToolkit.RUTA_WORD_TYPE_NAME);
      Type numType = ts.getType(TextRulerToolkit.RUTA_NUM_TYPE_NAME);
      Type markupType = ts.getType(TextRulerToolkit.RUTA_MARKUP_TYPE_NAME);
      Type specialType = ts.getType(TextRulerToolkit.RUTA_SPECIAL_TYPE_NAME);
      isRegExpType = ts.subsumes(wType, tokenAnnotation.getType())
              || ts.subsumes(markupType, tokenAnnotation.getType())
              || ts.subsumes(numType, tokenAnnotation.getType())
              || ts.subsumes(specialType, tokenAnnotation.getType());
    }
  }
View Full Code Here

        // for testpurposes
        // in order to test WHISK with PosTag Terms...
        if (posTagRootTypeName != null && posTagRootTypeName.length() > 0) {
          TextRulerAnnotation tokenAnnotation = term.getWordConstraint().getTokenAnnotation();
          CAS cas = example.getDocumentCAS();
          TypeSystem ts = cas.getTypeSystem();
          Type posTagsRootType = ts.getType(posTagRootTypeName);
          if (ts != null) {
            // POS-Tags created by our test hmm tagger.
            List<AnnotationFS> posTagAnnotations = TextRulerToolkit.getAnnotationsWithinBounds(cas,
                    tokenAnnotation.getBegin(), tokenAnnotation.getEnd(), null, posTagsRootType);
            if (posTagAnnotations.size() > 0) {
View Full Code Here

  public String getText(Object element) {

    String result = "error";
    if (element instanceof IExplainTreeNode) {
      IExplainTreeNode debugNode = (IExplainTreeNode) element;
      TypeSystem ts = debugNode.getTypeSystem();

      Type ruleType = ts.getType(ExplainConstants.RULE_APPLY_TYPE);
      FeatureStructure fs = debugNode.getFeatureStructure();
      if (fs != null && ts.subsumes(ruleType, fs.getType())) {
        Feature f1 = ruleType.getFeatureByBaseName(ExplainConstants.APPLIED);
        int v1 = fs.getIntValue(f1);
        Feature f2 = ruleType.getFeatureByBaseName(ExplainConstants.TRIED);
        int v2 = fs.getIntValue(f2);
        Feature f3 = ruleType.getFeatureByBaseName(ExplainConstants.ELEMENT);
View Full Code Here

  protected List<LP2Rule> createStartRulesForExample(final TextRulerExample example) {
    TextRulerTarget target = example.getTarget();
    List<LP2Rule> result = new ArrayList<LP2Rule>();
    CAS docCas = example.getDocumentCAS();
    TextRulerAnnotation exampleAnnotation = example.getAnnotation();
    TypeSystem ts = docCas.getTypeSystem();
    Type tokensRootType = ts.getType(TextRulerToolkit.RUTA_ANY_TYPE_NAME);

    boolean isLeftBoundary = (target.type == MLTargetType.SINGLE_LEFT_BOUNDARY || target.type == MLTargetType.SINGLE_LEFT_CORRECTION);
    int thePosition = isLeftBoundary ? exampleAnnotation.getBegin() : exampleAnnotation.getEnd();
    List<AnnotationFS> leftContext = TextRulerToolkit.getAnnotationsBeforePosition(docCas,
            thePosition, windowSize,
View Full Code Here

            test.getTypeSystem().getTopType());
    List<Type> types = new ArrayList<Type>();
    Type stringType = run.getTypeSystem().getType(UIMAConstants.TYPE_STRING);
    Type basicType = run.getTypeSystem().getType(RutaEngine.BASIC_TYPE);

    TypeSystem typeSystem = test.getTypeSystem();
    Type annotationType = test.getAnnotationType();
    for (Type eachType : allTypes) {
      if (!excludedTypes.contains(eachType.getName())
              && !eachType.getName().equals(test.getDocumentAnnotation().getType().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

      a.setEnd(((AnnotationFS) fs).getEnd());
    }
    if (withFeatures) {
      CAS testCas = fs.getCAS();
//      CAS runCas = newFS.getCAS();
      TypeSystem testTS = testCas.getTypeSystem();
//      TypeSystem runTS = runCas.getTypeSystem();
      Type stringType = testTS.getType(UIMAConstants.TYPE_STRING);
      List<Feature> features = fs.getType().getFeatures();
      for (Feature feature : features) {
        Type range = feature.getRange();
        if (testTS.subsumes(stringType, range)) {
          String valueTest = fs.getStringValue(feature);
          Feature feature2 = newFS.getType().getFeatureByBaseName(feature.getShortName());
          newFS.setStringValue(feature2, valueTest);
        }
      }
View Full Code Here

      }
    }
  }

  private Collection<FeatureStructure> getFeatureStructures(List<Type> types, CAS cas) {
    TypeSystem typeSystem = cas.getTypeSystem();
    Type stringType = typeSystem.getType(UIMAConstants.TYPE_STRING);
    Collection<FeatureStructure> result = new HashSet<FeatureStructure>();
    AnnotationIndex<AnnotationFS> annotationIndex = cas.getAnnotationIndex();
    for (AnnotationFS each : annotationIndex) {
      Type type = each.getType();
      for (Type eachType : types) {
        if(typeSystem.subsumes(eachType, type)) {
          List<Feature> features = each.getType().getFeatures();
          for (Feature feature : features) {
            Type range = feature.getRange();
            if (typeSystem.subsumes(stringType, range)) {
              result.add(each);
              break;
            }
          }
        }
View Full Code Here

  @Override
  public String getText(Object element) {
    if (element instanceof IExplainTreeNode) {
      IExplainTreeNode debugNode = (IExplainTreeNode) element;
      TypeSystem ts = debugNode.getTypeSystem();

      if (element instanceof RuleElementMatchesNode) {
        Type type = ts.getType(ExplainConstants.RULE_ELEMENT_MATCHES_TYPE);
        FeatureStructure fs = debugNode.getFeatureStructure();
        Feature f = type.getFeatureByBaseName(ExplainConstants.ELEMENT);
        Feature fanchor = type.getFeatureByBaseName(ExplainConstants.RULE_ANCHOR);
        if (f != null && fanchor != null) {
          String v = fs.getStringValue(f);
          return v;
        }
      } else if (element instanceof RuleElementMatchNode) {
        FeatureStructure fs = debugNode.getFeatureStructure();
        if (fs instanceof AnnotationFS) {
          String s = ((AnnotationFS) fs).getCoveredText();
          s = s.replaceAll("[\\n\\r]", "");

          return s;
        }
      } else if (element instanceof ConditionNode) {
        Type type = ts.getType(ExplainConstants.EVAL_CONDITION_TYPE);
        FeatureStructure fs = debugNode.getFeatureStructure();
        Feature f = type.getFeatureByBaseName(ExplainConstants.ELEMENT);
        if (f != null) {
          String v = fs.getStringValue(f);
          return v;
View Full Code Here

      if (!(a11.getBegin() == a22.getBegin() && a11.getEnd() == a22.getEnd())) {
        return false;
      }
    }
    CAS cas = a1.getCAS();
    TypeSystem typeSystem = cas.getTypeSystem();
    Type stringType = typeSystem.getType(UIMAConstants.TYPE_STRING);
    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(stringType, range)) {
        String name = eachFeature1.getShortName();
        Feature eachFeature2 = type2.getFeatureByBaseName(name);
        String featureValue1 = a1.getStringValue(eachFeature1);
        String featureValue2 = a2.getStringValue(eachFeature2);
        allEmpty1 &= featureValue1 == null;
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.