Examples of RutaBlock


Examples of org.apache.uima.ruta.RutaBlock

      resetEnvironment(module, cas);
    }
  }

  private void resetEnvironment(RutaModule module, CAS cas) {
    RutaBlock block = module.getBlock(null);
    block.getEnvironment().reset(cas);
    Collection<RutaBlock> blocks = module.getBlocks().values();
    for (RutaBlock each : blocks) {
      each.getEnvironment().reset(cas);
    }
  }
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

    }
  }

  private void initializeTypes(RutaModule script, CAS cas) {
    // TODO find a better solution for telling everyone about the types!
    RutaBlock mainRootBlock = script.getBlock(null);
    mainRootBlock.getEnvironment().initializeTypes(cas, strictImports);
    Collection<RutaModule> values = script.getScripts().values();
    for (RutaModule eachModule : values) {
      relinkEnvironments(eachModule, mainRootBlock, new ArrayList<RutaModule>());
      // initializeTypes(eachModule, cas);
    }
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

  private void relinkEnvironments(RutaModule script, RutaBlock mainRootBlock,
          Collection<RutaModule> processed) {
    if (!processed.contains(script)) {
      processed.add(script);
      RutaBlock block = script.getBlock(null);
      block.setParent(mainRootBlock);
      Collection<RutaModule> innerScripts = script.getScripts().values();
      for (RutaModule module : innerScripts) {
        relinkEnvironments(module, mainRootBlock, processed);
      }
    }
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

    return featureStringExpression;
  }

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaBlock parent = element.getParent();
    String featureString = featureStringExpression.getStringValue(parent, match, element, stream);
    List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotationsOf(element);
    for (AnnotationFS annotationFS : matchedAnnotations) {
      Feature feature = annotationFS.getType().getFeatureByBaseName(featureString);
      if (feature != null) {
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    List<Integer> indexes = new ArrayList<Integer>();
    for (INumberExpression each : indexExprList) {
      RutaBlock parent = element.getParent();
      int integerValue = each.getIntegerValue(parent, match, element, stream);
      indexes.add(integerValue);
    }
    List<RuleElement> ruleElements = element.getContainer().getRuleElements();
    for (Integer each : indexes) {
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

    this.expression = e;
  }

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaBlock parent = element.getParent();
    RutaEnvironment environment = parent.getEnvironment();
    Class<?> clazz = environment.getVariableType(var);
    if (clazz.equals(Integer.class) && expression instanceof INumberExpression) {
      int v = ((INumberExpression) expression).getIntegerValue(parent, match, element, stream);
      environment.setVariableValue(var, v);
    } else if (clazz.equals(Double.class) && expression instanceof INumberExpression) {
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

    this.level = level == null ? Level.INFO : level;
  }

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaBlock parent = element.getParent();
    String msg = text.getStringValue(parent, match, element, stream);
    Logger.getLogger(LOGGER_NAME).log(level, msg);
  }
View Full Code Here

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<?>[] beginMap = beginAnchor.getBeginMap();
        Set<AnnotationFS> aset = new HashSet<AnnotationFS>();
        for (Collection<?> set : beginMap) {
          if(set != null) {
            aset.addAll((Collection<? extends AnnotationFS>) 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();
        Collection<?>[] endMap = endAnchor.getEndMap();
        Set<AnnotationFS> aset = new HashSet<AnnotationFS>();
        for (Collection<?> set : endMap) {
          if(set != null) {
            aset.addAll((Collection<? extends AnnotationFS>) 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

Examples of org.apache.uima.ruta.RutaBlock

            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

Examples of org.apache.uima.ruta.RutaBlock

  }

  @SuppressWarnings({ "unchecked", "rawtypes" })
  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaBlock parent = element.getParent();
    RutaEnvironment environment = parent.getEnvironment();
    List list = environment.getVariableValue(var, List.class);
    // Class<?> vtype = environment.getVariableType(var);
    Class<?> vgtype = environment.getVariableGenericType(var);
    for (IRutaExpression each : elements) {
      if (each instanceof ListExpression) {
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.