Package org.apache.uima.ruta

Examples of org.apache.uima.ruta.RutaBlock


    this.opExpr = op;
  }

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaBlock parent = element.getParent();
    String op = opExpr.getStringValue(parent, match, element, stream);
    List<Type> list = new ArrayList<Type>();

    int indexOf = element.getContainer().getRuleElements().indexOf(element);
    List<Integer> indexes = new ArrayList<Integer>();
    indexes.add(indexOf + 1);
    List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(indexes,
            element.getContainer());
    for (AnnotationFS matched : matchedAnnotations) {

      if (TYPES_AT_BEGIN.equals(op)) {
        RutaBasic beginAnchor = stream.getBeginAnchor(matched.getBegin());
        Collection<Set<AnnotationFS>> values = beginAnchor.getBeginMap().values();
        Set<AnnotationFS> aset = new HashSet<AnnotationFS>();
        for (Set<AnnotationFS> set : values) {
          aset.addAll(set);
        }
        for (AnnotationFS annotationFS : aset) {
          list.add(annotationFS.getType());
        }
      } else if (TYPES_AT_END.equals(op)) {
        RutaBasic endAnchor = stream.getEndAnchor(matched.getEnd());
        Collection<Set<AnnotationFS>> values = endAnchor.getEndMap().values();
        Set<AnnotationFS> aset = new HashSet<AnnotationFS>();
        for (Set<AnnotationFS> set : values) {
          aset.addAll(set);
        }
        for (AnnotationFS annotationFS : aset) {
          list.add(annotationFS.getType());
        }
      } else if (TYPES.equals(op)) {
        Type annotationType = stream.getCas().getAnnotationType();
        List<AnnotationFS> inWindow = stream.getAnnotationsInWindow(matched, annotationType);
        for (AnnotationFS each : inWindow) {
          if (each.getBegin() == matched.getBegin() && each.getEnd() == matched.getEnd()) {
            list.add(each.getType());
          }
          if (each.getBegin() > matched.getBegin() || each.getEnd() < matched.getEnd()) {
            break;
          }
        }
      }
    }
    parent.getEnvironment().setVariableValue(var, list);
  }
View Full Code Here


            element.getContainer());
    for (AnnotationFS matchedAnnotation : matchedAnnotations) {
      List<RutaBasic> annotationsInWindow = stream.getBasicsInWindow(matchedAnnotation);
      boolean replaced = false;
      for (RutaBasic basic : annotationsInWindow) {
        RutaBlock parent = element.getParent();
        basic.setReplacement(replaced ? "" : replacement.getStringValue(parent, match, element,
                stream));
        replaced = true;
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.uima.ruta.RutaBlock

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.