Examples of RutaBlock


Examples of org.apache.uima.ruta.RutaBlock

    this.greedyRule = active2 == null ? new SimpleBooleanExpression(false) : active2;
  }

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaBlock parent = element.getParent();
    boolean greedy1 = greedyRuleElement.getBooleanValue(parent, match, element, stream);
    boolean greedy2 = greedyRule.getBooleanValue(parent, match, element, stream);
    stream.setGreedyRuleElement(greedy1);
    stream.setGreedyRule(greedy2);
  }
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

Examples of org.apache.uima.ruta.RutaBlock

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

Examples of org.apache.uima.ruta.RutaBlock

    this.parameterMap = map;
  }

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaBlock parent = element.getParent();
    RutaModule thisScript = parent.getScript();
    AnalysisEngine targetEngine = thisScript.getEngine(namespace);
    ConfigurationParameterDeclarations configurationParameterDeclarations = targetEngine
            .getAnalysisEngineMetaData().getConfigurationParameterDeclarations();

    Set<Entry<IStringExpression, IRutaExpression>> entrySet = parameterMap.entrySet();
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

  }

  protected void fillFeatures(TOP structure, Map<IStringExpression, IRutaExpression> features,
          AnnotationFS matchedAnnotation, RuleElement element, RutaStream stream) {
    Map<String, IRutaExpression> map = new HashMap<String, IRutaExpression>();
    RutaBlock parent = element.getParent();
    for (Entry<IStringExpression, IRutaExpression> each : features.entrySet()) {
      String value = each.getKey().getStringValue(parent, matchedAnnotation, stream);
      map.put(value, each.getValue());
    }
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

  }

  @SuppressWarnings({ "rawtypes" })
  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaBlock parent = element.getParent();
    List list = parent.getEnvironment().getVariableValue(var, List.class);
    List<Object> toRemove = new ArrayList<Object>();
    for (Object entry : list) {
      Object value1 = getValue(entry, parent, stream);
      for (IRutaExpression arg : elements) {
        if (arg instanceof ListExpression) {
          ListExpression l = (ListExpression) arg;
          List list2 = l.getList(parent, stream);
          for (Object object : list2) {
            Object value2 = getValue(object, parent, stream);
            if (value1.equals(value2)) {
              toRemove.add(entry);
            }
          }
        } else {
          Object value2 = getValue(arg, parent, stream);
          if (value1.equals(value2)) {
            toRemove.add(entry);
          }
        }
      }
    }
    for (Object object : toRemove) {
      list.remove(object);
    }
    parent.getEnvironment().setVariableValue(var, list);
  }
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {

    Map<String, Type> typeMap = new HashMap<String, Type>();
    RutaBlock parent = element.getParent();
    for (IStringExpression eachKey : map.keySet()) {
      String stringValue = eachKey.getStringValue(parent, match, element, stream);
      TypeExpression typeExpression = map.get(eachKey);
      if (typeExpression != null) {
        Type typeValue = typeExpression.getType(parent);
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOf(element);
    for (AnnotationFS annotationFS : matchedAnnotationsOf) {
      RutaStream windowStream = stream.getWindowStream(annotationFS, annotationFS.getType());
      RutaWordList wl = null;
      RutaBlock parent = element.getParent();
      if (list != null) {
        wl = list.getList(parent);
      } else if (stringList != null) {
        wl = new TreeWordList(stringList.getList(parent, stream));
      }
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);
View Full Code Here

Examples of org.apache.uima.ruta.RutaBlock

  }

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    List<Type> types = new ArrayList<Type>();
    RutaBlock parent = element.getParent();
    if (element instanceof RutaRuleElement) {
      types = ((RutaRuleElement) element).getMatcher().getTypes(parent, stream);
    }
    if (types == null)
      return;

    for (Type type : types) {
      String stringValue = featureStringExpression.getStringValue(parent, match, element, stream);
      Feature featureByBaseName = type.getFeatureByBaseName(stringValue);
      RutaEnvironment environment = parent.getEnvironment();
      List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotationsOf(element);
      for (AnnotationFS annotationFS : matchedAnnotations) {
        if (annotationFS.getType().getFeatureByBaseName(stringValue) == null) {
          System.out.println("Can't access feature " + stringValue
                  + ", because it's not defined in the matched type: " + annotationFS.getType());
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.