Package org.apache.uima.cas

Examples of org.apache.uima.cas.FeaturePath


  static Collection<AnnotationFS> getAnnotation(CAS cas, Type type, Span span) {
    ConstraintFactory cf = cas.getConstraintFactory();

    Type annotationType = cas.getAnnotationType();

    FeaturePath beginPath = cas.createFeaturePath();
    beginPath.addFeature(annotationType.getFeatureByBaseName("begin"));
    FSIntConstraint beginConstraint = cf.createIntConstraint();
    beginConstraint.geq(span.getStart());

    FSMatchConstraint embeddedBegin = cf.embedConstraint(beginPath, beginConstraint);

    FeaturePath endPath = cas.createFeaturePath();
    endPath.addFeature(annotationType.getFeatureByBaseName("end"));
    FSIntConstraint endConstraint = cf.createIntConstraint();
    endConstraint.leq(span.getEnd());

    FSMatchConstraint embeddedEnd = cf.embedConstraint(endPath, endConstraint);
View Full Code Here


    Iterator<Type> it = ts.getTypeIterator();
    //Type annotationType = ts.getType(Annotation.class.getName()); // this returns "org.apache.uima.tcas.Annotation" which isn't in type system
    Type annotationType = ts.getType("uima.tcas.Annotation"); // should be safe to hard code this
    //System.err.println("annotation type: " + annotationType);
    Feature sentenceBeginFeature = annotationType.getFeatureByBaseName("begin");
    FeaturePath sentenceBeginFeaturePath = jcas.createFeaturePath();
    sentenceBeginFeaturePath.addFeature(sentenceBeginFeature);
   
    Feature sentenceEndFeature = annotationType.getFeatureByBaseName("end");
    FeaturePath sentenceEndFeaturePath = jcas.createFeaturePath();
    sentenceEndFeaturePath.addFeature(sentenceEndFeature);
   
    FSMatchConstraint beginAndEnd = constructConstraintByBeginEnd(
        problemBegin, problemEnd, cf, sentenceBeginFeaturePath,
        sentenceEndFeaturePath);
   
View Full Code Here

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

  }

  private FSMatchConstraint createWindowConstraint(AnnotationFS windowAnnotation, CAS cas) {
    if (windowAnnotation == null)
      return null;
    FeaturePath beginFP = cas.createFeaturePath();
    Type type = windowAnnotation.getType();
    beginFP.addFeature(type.getFeatureByBaseName("begin"));
    FSIntConstraint intConstraint = cf.createIntConstraint();
    intConstraint.geq(windowAnnotation.getBegin());
    FSMatchConstraint beginConstraint = cf.embedConstraint(beginFP, intConstraint);

    FeaturePath endFP = cas.createFeaturePath();
    endFP.addFeature(type.getFeatureByBaseName("end"));
    intConstraint = cf.createIntConstraint();
    intConstraint.leq(windowAnnotation.getEnd());
    FSMatchConstraint endConstraint = cf.embedConstraint(endFP, intConstraint);

    FSMatchConstraint windowConstraint = cf.and(beginConstraint, endConstraint);
View Full Code Here

       
        void addFeatures (JCas jcas, Collection<String> featureNames)
        {
            for (Iterator<String> it = featureNames.iterator(); it.hasNext();) {
                String featureName = it.next();
                FeaturePath featurePath = jcas.createFeaturePath();
                Feature feature = jcas.getCasType(m_typeId).getFeatureByBaseName(featureName);
                featurePath.addFeature(feature);
                m_feat2path.put(featureName, featurePath);
            }
        }
View Full Code Here

                                            int     begin_lower,
                                            int     begin_upper,
                                            int     end_lower,
                                            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);
View Full Code Here

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

  }

  private FSMatchConstraint createWindowConstraint(AnnotationFS windowAnnotation, CAS cas) {
    if (windowAnnotation == null)
      return null;
    FeaturePath beginFP = cas.createFeaturePath();
    Type type = windowAnnotation.getType();
    beginFP.addFeature(type.getFeatureByBaseName("begin"));
    FSIntConstraint intConstraint = cf.createIntConstraint();
    intConstraint.geq(windowAnnotation.getBegin());
    FSMatchConstraint beginConstraint = cf.embedConstraint(beginFP, intConstraint);

    FeaturePath endFP = cas.createFeaturePath();
    endFP.addFeature(type.getFeatureByBaseName("end"));
    intConstraint = cf.createIntConstraint();
    intConstraint.leq(windowAnnotation.getEnd());
    FSMatchConstraint endConstraint = cf.embedConstraint(endFP, intConstraint);

    FSMatchConstraint windowConstraint = cf.and(beginConstraint, endConstraint);
View Full Code Here

  public Collection<AnnotationFS> getAnnotation(Type type, Span span) {
    ConstraintFactory cf = getCAS().getConstraintFactory();

    Type annotationType = getCAS().getAnnotationType();

    FeaturePath beginPath = getCAS().createFeaturePath();
    beginPath.addFeature(annotationType.getFeatureByBaseName("begin"));
    FSIntConstraint beginConstraint = cf.createIntConstraint();
    beginConstraint.geq(span.getStart());

    FSMatchConstraint embeddedBegin = cf.embedConstraint(beginPath, beginConstraint);

    FeaturePath endPath = getCAS().createFeaturePath();
    endPath.addFeature(annotationType.getFeatureByBaseName("end"));
    FSIntConstraint endConstraint = cf.createIntConstraint();
    endConstraint.leq(span.getEnd());

    FSMatchConstraint embeddedEnd = cf.embedConstraint(endPath, endConstraint);
View Full Code Here

  }

  private FSMatchConstraint createWindowConstraint(AnnotationFS windowAnnotation, CAS cas) {
    if (windowAnnotation == null)
      return null;
    FeaturePath beginFP = cas.createFeaturePath();
    Type type = windowAnnotation.getType();
    beginFP.addFeature(type.getFeatureByBaseName("begin"));
    FSIntConstraint intConstraint = cf.createIntConstraint();
    intConstraint.geq(windowAnnotation.getBegin());
    FSMatchConstraint beginConstraint = cf.embedConstraint(beginFP, intConstraint);

    FeaturePath endFP = cas.createFeaturePath();
    endFP.addFeature(type.getFeatureByBaseName("end"));
    intConstraint = cf.createIntConstraint();
    intConstraint.leq(windowAnnotation.getEnd());
    FSMatchConstraint endConstraint = cf.embedConstraint(endFP, intConstraint);

    FSMatchConstraint windowConstraint = cf.and(beginConstraint, endConstraint);
View Full Code Here

TOP

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

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.