Package org.apache.uima.ruta

Examples of org.apache.uima.ruta.RutaBlock


    this.factor = factor;
  }

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaBlock parent = element.getParent();
    boolean activated = active.getBooleanValue(parent, null, stream);
    stream.setDynamicAnchoring(activated);
    if (panelty != null) {
      double p = panelty.getDoubleValue(parent, null, stream);
      stream.setIndexPenalty(p);
View Full Code Here


  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    List<Integer> indexes = new ArrayList<Integer>();
    for (NumberExpression 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

  }

  protected void callScript(String blockName, RuleMatch match, RuleElement element,
          RutaStream stream, InferenceCrowd crowd, RutaModule targetScript) {
    RutaBlock block = targetScript.getBlock(blockName);
    if (block == null) {
      return;
    }
    List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOf(element);
    for (AnnotationFS annotationFS : matchedAnnotationsOf) {
      RutaStream windowStream = stream.getWindowStream(annotationFS,
              stream.getDocumentAnnotationType());
      ScriptApply apply = block.apply(windowStream, crowd);
      match.addDelegateApply(this, apply);
    }

  }
View Full Code Here

    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<?> list = listExpr.getList(parent, stream);
    if ("dominant".equals(op)) {
      parent.getEnvironment().setVariableValue(var, getDominant(list, parent));
    }
  }
View Full Code Here

  private void gatherFeatures(TOP structure, Map<StringExpression, RutaExpression> features,
          AnnotationFS matchedAnnotation, RuleElement element, RuleMatch match, RutaStream stream) {
    Map<String, List<Number>> map = new HashMap<String, List<Number>>();
    for (Entry<StringExpression, RutaExpression> each : features.entrySet()) {
      RutaBlock parent = element.getParent();
      String value = each.getKey().getStringValue(parent, match, element, stream);
      RutaExpression expr = each.getValue();
      List<Number> ints = new ArrayList<Number>();
      if (expr instanceof NumberExpression) {
        NumberExpression ne = (NumberExpression) expr;
View Full Code Here

    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 NumberExpression) {
      int v = ((NumberExpression) expression).getIntegerValue(parent, match, element, stream);
      environment.setVariableValue(var, v);
    } else if (clazz.equals(Double.class) && expression instanceof NumberExpression) {
View Full Code Here

      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

    }
  }

  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);
    Collection<RutaModule> values = script.getScripts().values();
    for (RutaModule eachModule : values) {
      relinkEnvironments(eachModule, mainRootBlock, new ArrayList<RutaModule>());
      // initializeTypes(eachModule, cas);
    }
View Full Code Here

  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

    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

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.