Package org.apache.uima.ruta.rule

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


      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 IBooleanExpression && list instanceof BooleanListExpression) {
        IBooleanExpression e = (IBooleanExpression) 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 INumberExpression && list instanceof NumberListExpression) {
        INumberExpression e = (INumberExpression) 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 IStringExpression && list instanceof StringListExpression) {
        IStringExpression e = (IStringExpression) 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


  public EvaluatedCondition eval(AnnotationFS annotation, RuleElement element, RutaStream stream,
          InferenceCrowd crowd) {
    if (!isWorkingOnList()) {
      Type t = type.getType(element.getParent());
      boolean result = check(annotation, stream, t);
      return new EvaluatedCondition(this, result);
    } else {
      boolean result = false;
      List<Type> types = getList().getList(element.getParent(), stream);
      for (Type t : types) {
        result |= check(annotation, stream, t);
        if (result == true) {
          break;
        }
      }
      return new EvaluatedCondition(this, result);
    }
  }
View Full Code Here

    if (stringExpr != null) {
      String value = annotation.getStringValue(featureByBaseName);
      String string = stringExpr.getStringValue(element.getParent(), null, stream);
      boolean result = string != null && string.equals(value);
      return new EvaluatedCondition(this, result);
    } else if (numberExpr != null) {
      String range = featureByBaseName.getRange().getName();
      boolean result = false;
      if (range.equals(UIMAConstants.TYPE_INTEGER)) {
        int value = annotation.getIntValue(featureByBaseName);
        int v = numberExpr.getIntegerValue(element.getParent(), annotation, stream);
        result = value == v;
      } else if (range.equals(UIMAConstants.TYPE_DOUBLE)) {
        double value = annotation.getDoubleValue(featureByBaseName);
        double v = numberExpr.getDoubleValue(element.getParent(), annotation, stream);
        result = value == v;
      } else if (range.equals(UIMAConstants.TYPE_FLOAT)) {
        float value = annotation.getFloatValue(featureByBaseName);
        float v = numberExpr.getFloatValue(element.getParent(), annotation, stream);
        result = value == v;
      } else if (range.equals(UIMAConstants.TYPE_BYTE)) {
        byte value = annotation.getByteValue(featureByBaseName);
        byte v = (byte) numberExpr.getIntegerValue(element.getParent(), annotation, stream);
        result = value == v;
      } else if (range.equals(UIMAConstants.TYPE_SHORT)) {
        short value = annotation.getShortValue(featureByBaseName);
        short v = (short) numberExpr.getIntegerValue(element.getParent(), annotation, stream);
        result = value == v;
      } else if (range.equals(UIMAConstants.TYPE_LONG)) {
        long value = annotation.getLongValue(featureByBaseName);
        long v = numberExpr.getIntegerValue(element.getParent(), annotation, stream);
        result = value == v;
      }
      return new EvaluatedCondition(this, result);
    } else if (booleanExpr != null) {
      boolean value = annotation.getBooleanValue(featureByBaseName);
      boolean v = booleanExpr.getBooleanValue(element.getParent(), annotation, stream);
      boolean result = value == v;
      return new EvaluatedCondition(this, result);
    } else if (typeExpr != null) {
      // String value = expandAnchor.getStringValue(featureByBaseName);
      // String string = stringExpr.getStringValue(element.getParent());
      // boolean result = string != null && string.equals(value);
      // return new EvaluatedCondition(this, result);
    }
    return new EvaluatedCondition(this, false);
  }
View Full Code Here

        regularExpPattern = Pattern.compile(stringValue, Pattern.MULTILINE + Pattern.DOTALL);
      }
      matcher = regularExpPattern.matcher(variableValue);
    }
    boolean matches = matcher.matches();
    return new EvaluatedCondition(this, matches);
  }
View Full Code Here

      if (result) {
        break;
      }
    }

    return new EvaluatedCondition(this, result);
  }
View Full Code Here

    try {
      if (Integer.class.equals(type)) {
        text = normalizeNumber(text);
        int value = Integer.valueOf(text);
        env.setVariableValue(var, value);
        return new EvaluatedCondition(this, true);
      } else if (Double.class.equals(type)) {
        text = normalizeNumber(text);
        double value = Double.valueOf(text);
        env.setVariableValue(var, value);
        return new EvaluatedCondition(this, true);
      } else if (String.class.equals(type)) {
        env.setVariableValue(var, text);
        return new EvaluatedCondition(this, true);
      } else if (Boolean.class.equals(type)) {
        env.setVariableValue(var, Boolean.valueOf(text));
        return new EvaluatedCondition(this, true);
      } else if (Type.class.equals(type)) {
        Type value = stream.getCas().getTypeSystem().getType(text);
        env.setVariableValue(var, value);
        return new EvaluatedCondition(this, true);
      } else {
        return new EvaluatedCondition(this, false);
      }
    } catch (Exception e) {
      return new EvaluatedCondition(this, false);
    }
  }
View Full Code Here

  public EvaluatedCondition eval(AnnotationFS annotation, RuleElement element, RutaStream stream,
          InferenceCrowd crowd) {
    RutaBasic endAnchor = stream.getEndAnchor(annotation.getEnd());
    Type t = type.getType(element.getParent());
    boolean result = endAnchor.beginsWith(t) && endAnchor.endsWith(t);
    return new EvaluatedCondition(this, result);
  }
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);
  }
View Full Code Here

  }

  @Override
  public EvaluatedCondition eval(AnnotationFS annotation, RuleElement element, RutaStream stream,
          InferenceCrowd crowd) {
    return new EvaluatedCondition(this, expression.getBooleanValue(element.getParent(), null,
            stream));
  }
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);
  }
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.