Examples of RutaBlock


Examples of org.apache.uima.ruta.RutaBlock

  }

  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

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

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

    this.maxIgnoreChar = maxIgnoreChar;
  }

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaBlock block = element.getParent();
    RutaTable table = tableExpr.getTable(block);
    int index = indexExpr.getIntegerValue(block, match, element, stream);
    Type type = typeExpr.getType(block);
    Map<String, Integer> map = new HashMap<String, Integer>();
    for (IStringExpression each : featureMap.keySet()) {
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

  }

  @Override
  protected void callScript(String blockName, RuleMatch match, RuleElement element,
          RutaStream stream, InferenceCrowd crowd, RutaModule targetScript) {
    RutaBlock block = targetScript.getBlock(blockName);
    if (block == null) {
      return;
    }
    ScriptApply apply = block.apply(stream, crowd);
    match.addDelegateApply(this, apply);
  }
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

    Type casType = stream.getJCas().getCasType(RutaColoring.type);
    FeatureStructure newAnnotationFS = stream.getCas().createFS(casType);
    RutaColoring coloring = null;
    if (newAnnotationFS instanceof RutaColoring) {
      coloring = (RutaColoring) newAnnotationFS;
      RutaBlock parent = element.getParent();
      coloring.setBgColor(bgcolor.getStringValue(parent, match, element, stream));
      coloring.setFgColor(fgcolor.getStringValue(parent, match, element, stream));
      coloring.setSelected(selected.getBooleanValue(parent, match, element, stream));
      coloring.setTargetType(type.getType(parent).getName());
      coloring.addToIndexes();
View Full Code Here

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

Examples of org.apache.uima.ruta.RutaBlock

  public void endVisit(RutaElement element, ScriptApply result) {
    // TODO create UIMA stuff here not later -> save memory!
    if (element instanceof RutaStatement) {
      RutaStatement stmt = (RutaStatement) element;
      RutaBlock parent = stmt.getParent();
      Stack<ScriptApply> stack = applies.get(stmt);
      if (stack == null) {
        stack = new Stack<ScriptApply>();
        applies.put(stmt, stack);
      }
      // replace
      if (!stack.isEmpty()) {
        stack.pop();
      }
      stack.push(result);
      applies.put(stmt, stack);
      if (parent != null) {
        Stack<ScriptApply> parentStack = applies.get(parent);
        if (parentStack != null && !parentStack.isEmpty()) {
          ScriptApply parentApply = parentStack.peek();
          if (parentApply instanceof BlockApply) {
            BlockApply blockApply = (BlockApply) parentApply;
            if (element instanceof RutaRule && parent.getRule().equals(element)
                    && result instanceof RuleApply) {
              blockApply.setRuleApply((RuleApply) result);

              // } else {
              // blockApply.add(result);
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.