Examples of FSTypeConstraint


Examples of org.apache.uima.cas.FSTypeConstraint

          outputTypes.add(outputs[j].getName());
        }
      }
    }

    FSTypeConstraint constraint = ConstraintFactory.instance().createTypeConstraint();

    for (String typeName  : outputTypes) {
      // add type to constraint
      constraint.add(typeName);
    }
    return constraint;
  }
View Full Code Here

Examples of org.apache.uima.cas.FSTypeConstraint

  }

  protected FSMatchConstraint getConstraint(CAS cas) {
    ConstraintFactory cf = cas.getConstraintFactory();
    final FSTypeConstraint constraint = cf.createTypeConstraint();

    for (String each : getFilterSet()) {
      constraint.add(each);
    }
    constraint.add(RutaEngine.BASIC_TYPE);
    // TODO check if this is a legal alternative to "new NotConstraint(constraint)":
    FSMatchConstraint result = new FSMatchConstraint() {
      private static final long serialVersionUID = -6744378612440830298L;

      private final FSTypeConstraint c = constraint;
View Full Code Here

Examples of org.apache.uima.cas.FSTypeConstraint

    cas.getIndexRepository().addFS(cas.createAnnotation(tokenType, 14, 15));
    cas.getIndexRepository().addFS(cas.createAnnotation(sentenceType, 0, 15));

    // create filtered iterator over Tokens only
    FSIterator<AnnotationFS> it = cas.getAnnotationIndex().iterator();
    FSTypeConstraint constraint = cas.getConstraintFactory().createTypeConstraint();
    constraint.add(tokenType);
   
    it = cas.createFilteredIterator(it, constraint);

    // do iteration
    while (it.isValid()) {
      AnnotationFS a = (AnnotationFS) it.get();
      assertTrue(a.getType().equals(tokenType));
      // System.out.println("Annotation type: " + a.getType().getName());
      // System.out.println("Covered text: " + a.getCoveredText());
      it.moveToNext();
    }

    // Count number of annotations.
    it = cas.getAnnotationIndex().iterator();
    int countAll = 0;
    for (it.moveToFirst(); it.isValid(); it.moveToNext()) {
      ++countAll;
    }

    // create filtered iterator over annotations
    it = cas.getAnnotationIndex().iterator();
    constraint = cas.getConstraintFactory().createTypeConstraint();
    constraint.add(annotationType);
    it = cas.createFilteredIterator(it, constraint);

    // do iteration
    int countFiltered = 0;
    while (it.isValid()) {
View Full Code Here

Examples of org.apache.uima.cas.FSTypeConstraint

    cas.getIndexRepository().addFS(cas.createAnnotation(tokenType, 14, 15));
    cas.getIndexRepository().addFS(cas.createAnnotation(sentenceType, 0, 15));

    // create filtered iterator over Tokens only
    FSIterator<AnnotationFS> it = cas.getAnnotationIndex().iterator();
    FSTypeConstraint constraint = cas.getConstraintFactory().createTypeConstraint();
    constraint.add(tokenType.getName());
    it = cas.createFilteredIterator(it, constraint);

    // do iteration
    while (it.isValid()) {
      AnnotationFS a = (AnnotationFS) it.get();
View Full Code Here

Examples of org.apache.uima.cas.FSTypeConstraint

      cas.getIndexRepository().addFS(token);

      FSIterator<AnnotationFS> it = cas.getAnnotationIndex(tokenType).iterator();

      ConstraintFactory cf = this.cas.getConstraintFactory();
      FSTypeConstraint tc = cf.createTypeConstraint();
      tc.add(sepType);
      tc.add(eosType.getName());
      ArrayList<String> path = new ArrayList<String>();
      path.add(tokenTypeFeat.getShortName());
      FSMatchConstraint cons = cf.embedConstraint(path, tc);
      it = this.cas.createFilteredIterator(it, cons);
      int count = 0;
View Full Code Here

Examples of org.apache.uima.cas.FSTypeConstraint

          outputTypes.add(outputs[j].getName());
        }
      }
    }

    FSTypeConstraint constraint = ConstraintFactory.instance().createTypeConstraint();

    for (String typeName  : outputTypes) {
      // add type to constraint
      constraint.add(typeName);
    }
    return constraint;
  }
View Full Code Here

Examples of org.apache.uima.cas.FSTypeConstraint

        LanguagePrecondition {

  private static final long serialVersionUID = -5526826405334750929L;

  public LanguagePrecondition_impl() {
    FSTypeConstraint typeCon = ConstraintFactory.instance().createTypeConstraint();
    typeCon.add("uima.tcas.DocumentAnnotation");
    super.setFsMatchConstraint(typeCon);
    super.setFeatureName(CAS.FEATURE_BASE_NAME_LANGUAGE);
    super.setPredicate(LANGUAGE_SUBSUMED);
  }
View Full Code Here

Examples of org.apache.uima.cas.FSTypeConstraint

      // get iterator over all annotations in the CAS
      FSIterator iterator = aCAS.getAnnotationIndex().iterator();

      // filter the iterator so that only instances of Types in the
      // mContainingAnnotationTypes array are returned
      FSTypeConstraint constraint = aCAS.getConstraintFactory().createTypeConstraint();
      for (int i = 0; i < mContainingAnnotationTypes.length; i++) {
        constraint.add(mContainingAnnotationTypes[i]);
      }
      iterator = aCAS.createFilteredIterator(iterator, constraint);

      // iterate over annotations and add them to an ArrayList
      List annotationList = new ArrayList();
View Full Code Here

Examples of org.apache.uima.cas.FSTypeConstraint

    FSMatchConstraint beginAndEnd = constructConstraintByBeginEnd(
        problemBegin, problemEnd, cf, sentenceBeginFeaturePath,
        sentenceEndFeaturePath);
   
   
    FSTypeConstraint sentenceTypeConstraint = cf.createTypeConstraint();
    sentenceTypeConstraint.add(sentenceType);
   
    FSMatchConstraint beginAndEndAndType = cf.and(beginAndEnd, sentenceTypeConstraint);
   
    FSIterator<Annotation> filteredIterator =
        jcas.createFilteredIterator(jcas.getAnnotationIndex().iterator(),  beginAndEndAndType);
View Full Code Here

Examples of org.apache.uima.cas.FSTypeConstraint

  }

  private FSIterator<AnnotationFS> getIteratorForDisjunctive(CAS cas, List<Type> types,
          boolean after, AnnotationFS annotation, RutaStream stream) {
    ConstraintFactory cf = cas.getConstraintFactory();
    FSTypeConstraint typeConstraint = cf.createTypeConstraint();
    for (Type each : types) {
      typeConstraint.add(each);
    }
    FSIterator<AnnotationFS> windowIt = cas.getAnnotationIndex().subiterator(
            stream.getDocumentAnnotation());
    FSIterator<AnnotationFS> iterator = cas.createFilteredIterator(windowIt, typeConstraint);
    if (annotation != null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.