Package org.apache.uima.ruta.rule

Examples of org.apache.uima.ruta.rule.EvaluatedCondition


      Date givenDate = dateFormat.parse(dateValue);
      int compareTo = matchedDate.compareTo(givenDate);
      result = compareTo < 0;
    } catch (Exception e) {
    }
    return new EvaluatedCondition(this, result);
  }
View Full Code Here


  public EvaluatedCondition eval(AnnotationFS annotation, RuleElement element, RutaStream stream,
          InferenceCrowd crowd) {
    String coveredText = annotation.getCoveredText();
    if (stringList == null) {
      RutaWordList wordList = listExpr.getList(element.getParent());
      return new EvaluatedCondition(this, wordList.contains(coveredText, false, 0, null, 0, true));
    }
    List<String> sList = stringList.getList(element.getParent(), stream);
    boolean contains = sList.contains(coveredText);
    return new EvaluatedCondition(this, contains);
  }
View Full Code Here

      if (var != null) {
        element.getParent().getEnvironment().setVariableValue(var, count);
      }
      boolean value = count >= min.getIntegerValue(element.getParent(), annotation, stream)
              && count <= max.getIntegerValue(element.getParent(), annotation, stream);
      return new EvaluatedCondition(this, value);
    } else {
      int count = 0;
      if (arg instanceof BooleanExpression && list instanceof BooleanListExpression) {
        BooleanExpression e = (BooleanExpression) arg;
        BooleanListExpression le = (BooleanListExpression) list;
        boolean v = e.getBooleanValue(element.getParent(), annotation, stream);
        List<Boolean> l = new ArrayList<Boolean>(le.getList(element.getParent(), stream));
        while (l.remove(v)) {
          count++;
        }
      } else if (arg instanceof NumberExpression && list instanceof NumberListExpression) {
        NumberExpression e = (NumberExpression) arg;
        NumberListExpression le = (NumberListExpression) list;
        Number v = e.getDoubleValue(element.getParent(), annotation, stream);
        List<Number> l = new ArrayList<Number>(le.getList(element.getParent(), stream));
        while (l.remove(v)) {
          count++;
        }
      } else if (arg instanceof StringExpression && list instanceof StringListExpression) {
        StringExpression e = (StringExpression) arg;
        StringListExpression le = (StringListExpression) list;
        String v = e.getStringValue(element.getParent(), annotation, stream);
        List<String> l = new ArrayList<String>(le.getList(element.getParent(), stream));
        while (l.remove(v)) {
          count++;
        }
      } else if (arg instanceof TypeExpression && list instanceof TypeListExpression) {
        TypeExpression e = (TypeExpression) arg;
        TypeListExpression le = (TypeListExpression) list;
        Type v = e.getType(element.getParent());
        List<Type> l = new ArrayList<Type>(le.getList(element.getParent(), stream));
        while (l.remove(v)) {
          count++;
        }
      }
      if (var != null) {
        element.getParent().getEnvironment().setVariableValue(var, count);
      }
      boolean value = count >= min.getIntegerValue(element.getParent(), annotation, stream)
              && count <= max.getIntegerValue(element.getParent(), annotation, stream);
      return new EvaluatedCondition(this, value);
    }
  }
View Full Code Here

      if (totalCount != 0) {
        percentValue = (((double) basicCount) / ((double) totalCount)) * 100;
      }
      boolean value = percentValue >= min.getDoubleValue(element.getParent(), annotation, stream)
              && percentValue <= max.getDoubleValue(element.getParent(), annotation, stream);
      return new EvaluatedCondition(this, value);
    } else {
      boolean value = anchorCount >= min.getIntegerValue(element.getParent(), annotation, stream)
              && anchorCount <= max.getIntegerValue(element.getParent(), annotation, stream);
      return new EvaluatedCondition(this, value);
    }
  }
View Full Code Here

  @Override
  public EvaluatedCondition eval(AnnotationFS annotation, RuleElement element, RutaStream stream,
          InferenceCrowd crowd) {
    if (expr instanceof BooleanExpression) {
      BooleanExpression be = (BooleanExpression) expr;
      return new EvaluatedCondition(this, be.getBooleanValue(element.getParent(), null, stream));
    } else if (expr instanceof FeatureMatchExpression) {
      FeatureMatchExpression fme = (FeatureMatchExpression) expr;
      TypeExpression typeExpr = fme.getTypeExpr();
      Type type = typeExpr.getType(element.getParent());
      List<AnnotationFS> annotations = getAnnotationsToCheck(annotation, type, fme, stream);
      Collection<AnnotationFS> featureAnnotations = fme.getFeatureAnnotations(annotations, stream,
              element.getParent(), true);
      return new EvaluatedCondition(this, !featureAnnotations.isEmpty());
    }
    return new EvaluatedCondition(this, false);
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.ruta.rule.EvaluatedCondition

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.