Package org.apache.uima.cas

Examples of org.apache.uima.cas.ConstraintFactory


public class FSUtil {
 
  @Deprecated
  public static FSIterator getAnnotationsInSpanIterator(JCas jcas, int type, int beginSpan, int endSpan)
  {
    ConstraintFactory constraintFactory = jcas.getConstraintFactory();
      FSIntConstraint windowConstraint = constraintFactory.createIntConstraint();
      windowConstraint.gt(beginSpan-1);
      windowConstraint.lt(endSpan);
     
      Type annotType = jcas.getCasType(type);
      Feature beginSpanFeature = annotType.getFeatureByBaseName("begin");
      Feature endSpanFeature = annotType.getFeatureByBaseName("end");
     
      FeaturePath beginFeaturePath = jcas.createFeaturePath();
      beginFeaturePath.addFeature(beginSpanFeature);
      FSMatchConstraint beginSpanConstraint = constraintFactory.embedConstraint(beginFeaturePath, windowConstraint);
     
      FeaturePath endFeaturePath = jcas.createFeaturePath();
      endFeaturePath.addFeature(endSpanFeature);
      FSMatchConstraint endSpanConstraint = constraintFactory.embedConstraint(endFeaturePath, windowConstraint);
     
      FSMatchConstraint spanConstraint = constraintFactory.and(beginSpanConstraint, endSpanConstraint);
     
      JFSIndexRepository indexes = jcas.getJFSIndexRepository();
      FSIndex<?> annotIndex = indexes.getAnnotationIndex(type);
      FSIterator<?> annotsInSpanItr = jcas.createFilteredIterator(annotIndex.iterator(), spanConstraint);
      return annotsInSpanItr;
View Full Code Here


    }
  }

  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());
View Full Code Here

    }
    return Collections.emptyList();
  }

  public FSMatchConstraint createAnchorConstraints(RutaBlock block, RutaStream stream) {
    ConstraintFactory cf = stream.getCas().getConstraintFactory();
    List<Type> types = getTypes(block, stream);
    FSMatchConstraint result = null;

    for (Type eachType : types) {
      BasicTypeConstraint anchorConstraint = new BasicTypeConstraint(cf.createTypeConstraint(),
              eachType);
      anchorConstraint.add(eachType);
      if (result != null) {
        result = cf.or(result, anchorConstraint);
      } else {
        result = anchorConstraint;
      }
    }
    return result;
View Full Code Here

    }

  }

  public FSIterator<AnnotationFS> getFilteredBasicIterator(FSMatchConstraint constraint) {
    ConstraintFactory cf = cas.getConstraintFactory();
    FSMatchConstraint matchConstraint = cf.and(constraint, filter.getDefaultConstraint());
    return cas.createFilteredIterator(basicIt, matchConstraint);
  }
View Full Code Here

    {
        EnclosedConstraintDescriptor ecDescr = new EnclosedConstraintDescriptor(jcas, Annotation.typeIndexID);
        FSMatchConstraint mcBounds = ecDescr.createConstraint(jcas, begin_lower, begin_upper, end_lower, end_upper);
       
        if ((null != enclosedTypes) && (0 < enclosedTypes.length)) {
            ConstraintFactory cf = jcas.getConstraintFactory();
            FSTypeConstraint tc = cf.createTypeConstraint();
            for (int i = 0; i < enclosedTypes.length; ++i) {
                tc.add(jcas.getCasType(enclosedTypes[i]));
            }
            mcBounds = cf.and(mcBounds, tc);
        }
        return ecDescr.createFilteredIterator(jcas, mcBounds);
    }
View Full Code Here

                                            int     end_upper)
        {
            FeaturePath begin_fp = m_feat2path.get("begin");             
            FeaturePath end_fp = m_feat2path.get("end");             

            ConstraintFactory cf = jcas.getConstraintFactory();
            FSIntConstraint bcLower = cf.createIntConstraint();
            bcLower.geq(begin_lower);
            FSMatchConstraint mcBegin = cf.embedConstraint(begin_fp, bcLower);
            if (begin_upper > begin_lower) {
                FSIntConstraint bcUpper = cf.createIntConstraint();
                bcUpper.lt(begin_upper);
                mcBegin = cf.and(mcBegin, cf.embedConstraint(begin_fp, bcUpper));
            }

            FSIntConstraint ecUpper = cf.createIntConstraint();
            ecUpper.leq(end_upper);        
            FSMatchConstraint mcEnd = cf.embedConstraint(end_fp, ecUpper);
            if (end_upper > end_lower) {
                FSIntConstraint ecLower = cf.createIntConstraint();
                ecLower.gt(end_lower);
                mcEnd = cf.and(mcEnd, cf.embedConstraint(end_fp, ecLower));
            }
           
            FSMatchConstraint mcBounds = cf.and(mcBegin, mcEnd);
            return mcBounds;
        }
View Full Code Here

        
        FSMatchConstraint createConstraint (JCas        jcas,
                                            String      feature_name,
                                            Object[]    values)
        {
            ConstraintFactory cf = jcas.getConstraintFactory();

            FeaturePath feature_path = m_feat2path.get(feature_name);
            FSMatchConstraint feat_mc = null;
            for (int i = 0; i < values.length; ++i) {
                FSStringConstraint val_sc = cf.createStringConstraint();
                val_sc.equals(values[i].toString());
                if (null == feat_mc) {
                    feat_mc = cf.embedConstraint(feature_path, val_sc);
                }
                else {
                    feat_mc = cf.or(feat_mc, cf.embedConstraint(feature_path, val_sc));
                }
            }
            return feat_mc;
        }
View Full Code Here

    }

  }

  public FSIterator<AnnotationFS> getFilteredBasicIterator(FSMatchConstraint constraint) {
    ConstraintFactory cf = cas.getConstraintFactory();
    FSMatchConstraint matchConstraint = cf.and(constraint, filter.getDefaultConstraint());
    return cas.createFilteredIterator(basicIt, matchConstraint);
  }
View Full Code Here

    }
    return Collections.emptyList();
  }

  public FSMatchConstraint createAnchorConstraints(RutaBlock block, RutaStream stream) {
    ConstraintFactory cf = stream.getCas().getConstraintFactory();
    List<Type> types = getTypes(block, stream);
    FSMatchConstraint result = null;

    for (Type eachType : types) {
      BasicTypeConstraint anchorConstraint = new BasicTypeConstraint(cf.createTypeConstraint(),
              eachType);
      anchorConstraint.add(eachType);
      if (result != null) {
        result = cf.or(result, anchorConstraint);
      } else {
        result = anchorConstraint;
      }
    }
    return result;
View Full Code Here

    }
  }

  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());
View Full Code Here

TOP

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

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.