Examples of EvaluatedCondition


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

          if (result == true) {
            break;
          }
        }
      }
      return new EvaluatedCondition(this, result);
    } else {
      boolean result = false;
      List<Type> types = getList().getList(element.getParent(), stream);
      for (Type type : types) {
        Collection<AnnotationFS> beginAnchors = beginAnchor.getBeginAnchors(type);
        if (beginAnchors != null) {
          for (AnnotationFS annotationFS : beginAnchors) {
            result |= check(annotation, annotationFS);
            if (result == true) {
              break;
            }
          }
        }
      }
      return new EvaluatedCondition(this, result);
    }
  }
View Full Code Here

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

      if (count >= minValue && it.isValid()) {
        FeatureStructure featureStructure = it.get();
        if (featureStructure instanceof RutaBasic) {
          RutaBasic each = (RutaBasic) featureStructure;
          if (each.isPartOf(type.getType(element.getParent()))) {
            return new EvaluatedCondition(this, true);
          }
        }
      }
      if (forwardValue) {
        it.moveToNext();
      } else {
        it.moveToPrevious();
      }
      count++;
    }
    return new EvaluatedCondition(this, false);
  }
View Full Code Here

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

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

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

    if (var != null) {
      element.getParent().getEnvironment().setVariableValue(var, score);
    }
    boolean value = score >= min.getDoubleValue(element.getParent(), null, stream)
            && score <= max.getDoubleValue(element.getParent(), null, stream);
    return new EvaluatedCondition(this, value);
  }
View Full Code Here

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

  @Override
  public EvaluatedCondition eval(AnnotationFS annotation, RuleElement element, RutaStream stream,
          InferenceCrowd crowd) {
    AbstractRutaCondition cond = conditions.get(0);
    crowd.beginVisit(cond, null);
    EvaluatedCondition eval = cond.eval(annotation, element, stream, crowd);
    crowd.endVisit(cond, null);
    return new EvaluatedCondition(this, !eval.isValue(), eval);
  }
View Full Code Here

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

    RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
    RutaBasic endAnchor = stream.getEndAnchor(annotation.getEnd());
    if (beginAnchor == null || endAnchor == null || !beginAnchor.isPartOf(t)
            || !endAnchor.isPartOf(t)) {
      return new EvaluatedCondition(this, false);
    }

    boolean relatively = relative == null ? true : relative.getBooleanValue(element.getParent(),
            annotation, stream);

    FSIterator<AnnotationFS> iterator = stream.getCas().getAnnotationIndex(t).iterator(beginAnchor);
    if (!iterator.isValid()) {
      iterator.moveToNext();
    }
    if (!iterator.isValid()) {
      iterator.moveToLast();
    }
    AnnotationFS window = null;
    while (iterator.isValid()) {
      AnnotationFS annotationFS = iterator.get();
      if (annotationFS.getBegin() <= annotation.getBegin()
              && annotationFS.getEnd() >= annotation.getEnd()) {
        window = annotationFS;
        break;
      }
      iterator.moveToPrevious();
    }

    List<Type> targetTypes = new ArrayList<Type>();
    if (element instanceof RutaRuleElement) {
      RutaRuleElement re = (RutaRuleElement) element;
      targetTypes.addAll(re.getMatcher().getTypes(element.getParent(), stream));
    } else {
      targetTypes.add(annotation.getType());
    }

    if (window == null) {
      return new EvaluatedCondition(this, false);
    }
    int integerValue = position.getIntegerValue(element.getParent(), annotation, stream);
    if (relatively) {
      int counter = 0;
      List<RutaBasic> inWindow = stream.getBasicsInWindow(window);
      for (RutaBasic each : inWindow) {
        if (beginsWith(each, targetTypes)) {
          counter++;
          if (counter == integerValue) {
            if (each.getBegin() == beginAnchor.getBegin()) {
              return new EvaluatedCondition(this, true);
            } else {
              return new EvaluatedCondition(this, false);
            }
          } else if (counter > integerValue) {
            return new EvaluatedCondition(this, false);
          }
        }
      }
      return new EvaluatedCondition(this, false);
    } else {
      int counter = 0;
      List<RutaBasic> inWindow = stream.getBasicsInWindow(window);
      for (RutaBasic each : inWindow) {
        counter++;
        boolean beginsWith = beginsWith(each, targetTypes);
        if (each.getBegin() == beginAnchor.getBegin() && beginsWith && counter == integerValue) {
          return new EvaluatedCondition(this, true);
        } else if (counter > integerValue) {
          return new EvaluatedCondition(this, false);
        }
      }
      return new EvaluatedCondition(this, false);
    }
  }
View Full Code Here

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

          RutaStream symbolStream, InferenceCrowd crowd) {
    boolean result = false;
    List<EvaluatedCondition> evals = new ArrayList<EvaluatedCondition>();
    for (AbstractRutaCondition each : conditions) {
      crowd.beginVisit(each, null);
      EvaluatedCondition eval = each.eval(currentSymbol, element, symbolStream, crowd);
      crowd.endVisit(each, null);
      result |= eval.isValue();
      evals.add(eval);
    }
    return new EvaluatedCondition(this, result, evals);
  }
View Full Code Here

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

    // TODO rewrite
    if (!isWorkingOnList()) {
      Type t = type.getType(element.getParent());
      boolean result = check(annotation, t, stream);
      return new EvaluatedCondition(this, result);
    } else {
      boolean result = false;
      List<Type> types = getList().getList(element.getParent(), stream);
      for (Type t : types) {
        result |= check(annotation, t, stream);
        if (result == true) {
          return new EvaluatedCondition(this, result);
        }
      }
    }
    boolean result = false;
    return new EvaluatedCondition(this, result);
  }
View Full Code Here

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

  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

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

    String text = annotation.getCoveredText();
    if(arg != null) {
      text = arg.getStringValue(element.getParent(), annotation, stream);
    }
    if(text == null) {
      return new EvaluatedCondition(this, false);
    }
    if (stringList == null) {
      RutaWordList wordList = listExpr.getList(element.getParent());
      return new EvaluatedCondition(this, wordList.contains(text, false, 0, null, 0, true));
    }
    List<String> sList = stringList.getList(element.getParent(), stream);
    boolean contains = sList.contains(text);
    return new EvaluatedCondition(this, contains);
  }
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.