Examples of NumberExpression


Examples of org.apache.uima.ruta.expression.number.NumberExpression

          Feature feature = type.getFeatureByBaseName(featureName);
          if (feature != null) {
            Object argExpr = eachEntry.getValue();
            Type range = feature.getRange();
            if (argExpr instanceof NumberExpression) {
              NumberExpression ne = (NumberExpression) argExpr;
              int cg = ne.getIntegerValue(getParent(), afs, stream);
              if (range.getName().equals(UIMAConstants.TYPE_STRING)) {
                String s = matchResult.group(cg);
                afs.setStringValue(feature, s);
              } else if (range.getName().equals(UIMAConstants.TYPE_BOOLEAN)) {
              } else if (range.getName().equals(UIMAConstants.TYPE_BYTE)) {
View Full Code Here

Examples of org.apache.uima.ruta.expression.number.NumberExpression

              numbers.add(number.floatValue());
            }
            targetEngine.setConfigParameterValue(stringValue, numbers.toArray());
          } else {
            if (value instanceof NumberExpression) {
              NumberExpression ne = (NumberExpression) value;
              Double d = ne.getDoubleValue(parent, match, element, stream);
              targetEngine.setConfigParameterValue(stringValue, d.floatValue());
            }
          }
        } else if (type.equals("Integer")) {
          if (value instanceof NumberListExpression) {
            NumberListExpression nle = (NumberListExpression) value;
            List<Number> list = nle.getList(parent, stream);
            List<Integer> numbers = new ArrayList<Integer>();
            for (Number number : list) {
              numbers.add(number.intValue());
            }
            targetEngine.setConfigParameterValue(stringValue, numbers.toArray());
          } else {
            if (value instanceof NumberExpression) {
              NumberExpression ne = (NumberExpression) value;
              Integer i = ne.getIntegerValue(parent, match, element, stream);
              targetEngine.setConfigParameterValue(stringValue, i);
            }
          }
        } else if (type.equals("Boolean")) {
          if (value instanceof BooleanListExpression) {
View Full Code Here

Examples of org.apache.uima.ruta.expression.number.NumberExpression

    Iterator<Entry<TypeExpression, NumberExpression>> iterator = rule.getTypeMap().entrySet()
            .iterator();
    while (iterator.hasNext()) {
      Entry<TypeExpression, NumberExpression> next = iterator.next();
      String type = verbalizer.verbalize(next.getKey());
      NumberExpression value = next.getValue();
      if (value != null) {
        String group = verbalizer.verbalize(value);
        sb.append(group + " = " + type);
      } else {
        sb.append(type);
View Full Code Here

Examples of org.apache.uima.ruta.expression.number.NumberExpression

      }
    } else if (argExpr instanceof NumberExpression
            && (range.equals(UIMAConstants.TYPE_INTEGER) || range.equals(UIMAConstants.TYPE_LONG)
                    || range.equals(UIMAConstants.TYPE_SHORT) || range
                      .equals(UIMAConstants.TYPE_BYTE))) {
      NumberExpression numberExpr = (NumberExpression) argExpr;
      int v = numberExpr.getIntegerValue(element.getParent(), a, stream);
      a.setIntValue(feature, v);
    } else if (argExpr instanceof NumberExpression && (range.equals(UIMAConstants.TYPE_DOUBLE))) {
      NumberExpression numberExpr = (NumberExpression) argExpr;
      double v = numberExpr.getDoubleValue(element.getParent(), a, stream);
      a.setDoubleValue(feature, v);
    } else if (argExpr instanceof NumberExpression && (range.equals(UIMAConstants.TYPE_FLOAT))) {
      NumberExpression numberExpr = (NumberExpression) argExpr;
      float v = numberExpr.getFloatValue(element.getParent(), a, stream);
      a.setFloatValue(feature, v);
    } else if (argExpr instanceof BooleanExpression && (range.equals(UIMAConstants.TYPE_BOOLEAN))) {
      BooleanExpression booleanExpr = (BooleanExpression) argExpr;
      boolean v = booleanExpr.getBooleanValue(element.getParent(), a, stream);
      a.setBooleanValue(feature, v);
View Full Code Here

Examples of org.apache.uima.ruta.expression.number.NumberExpression

    String var = "anyVar";
    TypeExpression typeExpr1 = new SimpleTypeExpression("Type1");
    TypeExpression typeExpr2 = new ReferenceTypeExpression("typeVar");
    typeExprList.add(typeExpr1);
    typeExprList.add(typeExpr2);
    NumberExpression numExpr1 = new SimpleNumberExpression(4);
    NumberExpression numExpr2 = new ReferenceNumberExpression("numVar");
    BooleanExpression boolExpr1 = new SimpleBooleanExpression(true);
    StringExpression stringExpr = new SimpleStringExpression("string");
    stringExprList.add(stringExpr);
    exprList.add(typeExpr1);
    WordTableExpression wordTableExpr = new ReferenceWordTableExpression(var);
View Full Code Here

Examples of org.apache.uima.ruta.expression.number.NumberExpression

    StringExpression varExpr = new ReferenceNumberExpression(var);
    TypeExpression typeExpr1 = new SimpleTypeExpression("Type1");
    TypeExpression typeExpr2 = new ReferenceTypeExpression("typeVar");
    typeExprList.add(typeExpr1);
    typeExprList.add(typeExpr2);
    NumberExpression numExpr1 = new SimpleNumberExpression(4);
    NumberExpression numExpr2 = new ReferenceNumberExpression("numVar");
    BooleanExpression boolExpr1 = new SimpleBooleanExpression(true);
    StringExpression stringExpr = new SimpleStringExpression("string");
    stringExprList.add(stringExpr);
    TypeListExpression typeListExpr = new SimpleTypeListExpression(typeExprList);
    StringListExpression stringListExpr = new SimpleStringListExpression(stringExprList);
View Full Code Here

Examples of org.apache.uima.ruta.expression.number.NumberExpression

        List<Boolean> l = new ArrayList<Boolean>(le.getList(element.getParent(), stream));
        while (l.remove(v)) {
          count++;
        }
      } else if (arg instanceof NumberExpression && list instanceof NumberListExpression) {
        NumberExpression e = (NumberExpression) arg;
        NumberListExpression le = (NumberListExpression) list;
        Number v = e.getDoubleValue(element.getParent(), annotation, stream);
        List<Number> l = new ArrayList<Number>(le.getList(element.getParent(), stream));
        while (l.remove(v)) {
          count++;
        }
      } else if (arg instanceof StringExpression && list instanceof StringListExpression) {
        StringExpression e = (StringExpression) arg;
        StringListExpression le = (StringListExpression) list;
        String v = e.getStringValue(element.getParent(), annotation, stream);
        List<String> l = new ArrayList<String>(le.getList(element.getParent(), stream));
        while (l.remove(v)) {
          count++;
        }
      } else if (arg instanceof TypeExpression && list instanceof TypeListExpression) {
        TypeExpression e = (TypeExpression) arg;
        TypeListExpression le = (TypeListExpression) list;
        Type v = e.getType(element.getParent());
        List<Type> l = new ArrayList<Type>(le.getList(element.getParent(), stream));
        while (l.remove(v)) {
          count++;
        }
      }
View Full Code Here

Examples of org.apache.uima.ruta.expression.number.NumberExpression

      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;
        ints.add(ne.getIntegerValue(parent, match, element, stream));
        map.put(value, ints);
      } else if (expr instanceof NumberListExpression) {
        NumberListExpression ne = (NumberListExpression) expr;
        map.put(value, ne.getList(parent, stream));
      }
    }

    TypeSystem typeSystem = stream.getCas().getTypeSystem();
    JCas jcas = stream.getJCas();
View Full Code Here

Examples of org.apache.uima.ruta.expression.number.NumberExpression

        List<Boolean> l = new ArrayList<Boolean>(le.getList(element.getParent(), stream));
        while (l.remove(v)) {
          basicCount++;
        }
      } else if (arg instanceof NumberExpression && argList instanceof NumberListExpression) {
        NumberExpression e = (NumberExpression) arg;
        NumberListExpression le = (NumberListExpression) argList;
        Number v = e.getDoubleValue(element.getParent(), annotation, stream);
        List<Number> l = new ArrayList<Number>(le.getList(element.getParent(), stream));
        while (l.remove(v)) {
          basicCount++;
        }
      } else if (arg instanceof StringExpression && argList instanceof StringListExpression) {
        StringExpression e = (StringExpression) arg;
        StringListExpression le = (StringListExpression) argList;
        String v = e.getStringValue(element.getParent(), annotation, stream);
        List<String> l = new ArrayList<String>(le.getList(element.getParent(), stream));
        while (l.remove(v)) {
          basicCount++;
        }
      } else if (arg instanceof TypeExpression && argList instanceof TypeListExpression) {
        TypeExpression e = (TypeExpression) arg;
        TypeListExpression le = (TypeListExpression) argList;
        Type v = e.getType(element.getParent());
        List<Type> l = new ArrayList<Type>(le.getList(element.getParent(), stream));
        while (l.remove(v)) {
          basicCount++;
        }
      }
View Full Code Here

Examples of org.apache.uima.ruta.expression.number.NumberExpression

      }
      sb.append(")");
      return sb.toString();
    } else if (condition instanceof ContainsCondition) {
      ContainsCondition c = (ContainsCondition) condition;
      NumberExpression minE = c.getMin();
      String min = verbalizeMin(minE, 1);
      NumberExpression maxE = c.getMax();
      String max = verbalizeMax(maxE, Integer.MAX_VALUE);
      String percent = verbalizer.verbalize(c.getPercent());
      percent = !percent.equals("false") ? ", " + percent : "";
      if (c.getType() != null) {
        String type = verbalizer.verbalize(c.getType());
        return name + type + min + max + percent + ")";
      } else {
        return name + verbalizer.verbalize(c.getArgList()) + ", "
                + verbalizer.verbalize(c.getArg()) + min + max + percent + ")";
      }
    } else if (condition instanceof ContextCountCondition) {
      ContextCountCondition c = (ContextCountCondition) condition;
      String type = verbalizer.verbalize(c.getType());
      NumberExpression minE = c.getMin();
      String min = verbalizeMin(minE, Integer.MIN_VALUE);
      NumberExpression maxE = c.getMax();
      String max = verbalizeMax(maxE, Integer.MAX_VALUE);
      String var = c.getVar() == null ? "" : ", " + c.getVar();
      return name + type + min + max + var + ")";
    } else if (condition instanceof CountCondition) {
      CountCondition c = (CountCondition) condition;
      if (c.getArg() == null) {
        String type = verbalizer.verbalize(c.getType());
        NumberExpression minE = c.getMin();
        String min = verbalizeMin(minE, Integer.MIN_VALUE);
        NumberExpression maxE = c.getMax();
        String max = verbalizeMax(maxE, Integer.MAX_VALUE);
        String var = c.getVar() == null ? "" : ", " + c.getVar();
        return name + type + min + max + var + ")";
      } else {
        String list = verbalizer.verbalize(c.getArgList());
        String arg = verbalizer.verbalize(c.getArg());
        NumberExpression minE = c.getMin();
        String min = verbalizeMin(minE, Integer.MIN_VALUE);
        NumberExpression maxE = c.getMax();
        String max = verbalizeMax(maxE, Integer.MAX_VALUE);
        String var = c.getVar() == null ? "" : ", " + c.getVar();
        return name + list + ", " + arg + min + max + var + ")";
      }
    } else if (condition instanceof CurrentCountCondition) {
      CurrentCountCondition c = (CurrentCountCondition) condition;
      String type = verbalizer.verbalize(c.getType());
      NumberExpression minE = c.getMin();
      String min = verbalizeMin(minE, Integer.MIN_VALUE);
      NumberExpression maxE = c.getMax();
      String max = verbalizeMax(maxE, Integer.MAX_VALUE);
      String var = c.getVar() == null ? "" : ", " + c.getVar();
      return name + type + min + max + var + ")";
    } else if (condition instanceof IfCondition) {
      IfCondition c = (IfCondition) condition;
      return name + verbalizer.verbalize(c.getExpression()) + ")";
    } else if (condition instanceof InListCondition) {
      InListCondition c = (InListCondition) condition;
      String list = "";
      if (c.getListExpression() != null) {
        list = verbalizer.verbalize(c.getListExpression());
      } else {
        list = verbalizer.verbalize(c.getStringList());
      }
      NumberExpression distE = c.getDistance();
      String dist = "";
      String rel = "";
      if (distE != null) {
        dist = ", " + verbalizer.verbalize(distE);
      }
      if (c.getRelative() != null) {
        rel = ", " + verbalizer.verbalize(c.getRelative());
      }
      return name + list + dist + rel + ")";
    } else if (condition instanceof LastCondition) {
      LastCondition c = (LastCondition) condition;
      return name + verbalizer.verbalize(c.getType()) + ")";
    } else if (condition instanceof MOfNCondition) {
      MOfNCondition c = (MOfNCondition) condition;
      StringBuilder sb = new StringBuilder();
      sb.append(name);

      NumberExpression minE = c.getMin();
      String min = verbalizeMin(minE, Integer.MIN_VALUE);
      NumberExpression maxE = c.getMax();
      String max = verbalizeMax(maxE, Integer.MAX_VALUE);
      sb.append(min.substring(2, min.length()));
      sb.append(max);
      List<AbstractRutaCondition> conditions = c.getConditions();
      if (!conditions.isEmpty()) {
        sb.append(", ");
      }
      Iterator<AbstractRutaCondition> it = conditions.iterator();
      while (it.hasNext()) {
        AbstractRutaCondition each = (AbstractRutaCondition) it.next();
        sb.append(verbalize(each));
        if (it.hasNext()) {
          sb.append(", ");
        }
      }
      sb.append(")");
      return sb.toString();
    } else if (condition instanceof NearCondition) {
      NearCondition c = (NearCondition) condition;
      String type = verbalizer.verbalize(c.getType());
      String var = verbalizer.verbalize(c.getForward());
      NumberExpression minE = c.getMin();
      String min = verbalizeMin(minE, Integer.MIN_VALUE);
      NumberExpression maxE = c.getMax();
      String max = verbalizeMax(maxE, Integer.MAX_VALUE);
      String filtered = verbalizer.verbalize(c.getFiltered());
      if (!"".equals(filtered)) {
        filtered = ", " + filtered;
      }
      return name + type + min + max + ", " + var + filtered + ")";
    } else if (condition instanceof NotCondition) {
      NotCondition c = (NotCondition) condition;
      List<AbstractRutaCondition> conditions = c.getConditions();
      if (conditions.size() != 1) {
        StringBuilder sb = new StringBuilder();
        sb.append(name);
        Iterator<AbstractRutaCondition> it = conditions.iterator();
        while (it.hasNext()) {
          AbstractRutaCondition each = (AbstractRutaCondition) it.next();
          sb.append(verbalize(each));
          if (it.hasNext()) {
            sb.append(", ");
          }
        }
        sb.append(")");
        return sb.toString();
      } else {
        return "-" + verbalize(conditions.get(0));
      }
    } else if (condition instanceof OrCondition) {
      OrCondition c = (OrCondition) condition;
      List<AbstractRutaCondition> conditions = c.getConditions();
      StringBuilder sb = new StringBuilder();
      sb.append(name);
      Iterator<AbstractRutaCondition> it = conditions.iterator();
      while (it.hasNext()) {
        AbstractRutaCondition each = (AbstractRutaCondition) it.next();
        sb.append(verbalize(each));
        if (it.hasNext()) {
          sb.append(", ");
        }
      }
      sb.append(")");
      return sb.toString();
    } else if (condition instanceof PartOfCondition) {
      PartOfCondition c = (PartOfCondition) condition;
      if (c.getType() == null) {
        return name + verbalizer.verbalize(c.getList()) + ")";
      } else {
        return name + verbalizer.verbalize(c.getType()) + ")";
      }
    } else if (condition instanceof PartOfNeqCondition) {
      PartOfNeqCondition c = (PartOfNeqCondition) condition;
      if (c.getType() == null) {
        return name + verbalizer.verbalize(c.getList()) + ")";
      } else {
        return name + verbalizer.verbalize(c.getType()) + ")";
      }
    } else if (condition instanceof PositionCondition) {
      PositionCondition c = (PositionCondition) condition;
      String relative = "";
      if (c.getRelative() != null) {
        relative = ", " + verbalizer.verbalize(c.getRelative());
      }
      return name + verbalizer.verbalize(c.getType()) + ", "
              + verbalizer.verbalize(c.getPosition()) + relative + ")";
    } else if (condition instanceof RegExpCondition) {
      RegExpCondition c = (RegExpCondition) condition;
      StringExpression variable = c.getVariable();
      String ic = verbalizer.verbalize(c.getIgnoreCase());
      if (variable == null) {
        return name + verbalizer.verbalize(c.getPattern()) + ", " + ic + ")";
      } else {
        return name + verbalizer.verbalize(variable) + ", " + verbalizer.verbalize(c.getPattern()) + ", " + ic + ")";
      }
    } else if (condition instanceof ScoreCondition) {
      ScoreCondition c = (ScoreCondition) condition;
      // String type = verbalizer.verbalize(c.getType());
      NumberExpression minE = c.getMin();
      String min = verbalizeMin(minE, Integer.MIN_VALUE);
      NumberExpression maxE = c.getMax();
      String max = verbalizeMax(maxE, Integer.MAX_VALUE);
      String var = c.getVar() == null ? "" : ", " + c.getVar();
      return name + min.substring(2) + max + var + ")";
    } else if (condition instanceof TotalCountCondition) {
      TotalCountCondition c = (TotalCountCondition) condition;
      String type = verbalizer.verbalize(c.getType());
      NumberExpression minE = c.getMin();
      String min = verbalizeMin(minE, Integer.MIN_VALUE);
      NumberExpression maxE = c.getMax();
      String max = verbalizeMax(maxE, Integer.MAX_VALUE);
      String var = c.getVar() == null ? "" : ", " + c.getVar();
      return name + type + min + max + var + ")";
    } else if (condition instanceof VoteCondition) {
      VoteCondition c = (VoteCondition) condition;
      String type1 = verbalizer.verbalize(c.getType1());
      String type2 = verbalizer.verbalize(c.getType2());
      return name + type1 + ", " + type2 + ")";
    } else if (condition instanceof FeatureCondition) {
      FeatureCondition c = (FeatureCondition) condition;
      String e1 = verbalizer.verbalize(c.getFeatureStringExpression());
      String e2 = "";
      if (c.getBooleanExpr() != null) {
        e2 = verbalizer.verbalize(c.getBooleanExpr());
      } else if (c.getNumberExpr() != null) {
        e2 = verbalizer.verbalize(c.getNumberExpr());
      } else if (c.getStringExpr() != null) {
        e2 = verbalizer.verbalize(c.getStringExpr());
      }
      return name + e1 + ", " + e2 + ")";
    } else if (condition instanceof ParseCondition) {
      ParseCondition c = (ParseCondition) condition;
      String var = c.getVar();
      return name + var + ")";
    } else if (condition instanceof IsCondition) {
      IsCondition c = (IsCondition) condition;
      String type = "";
      if (c.getType() != null) {
        type = verbalizer.verbalize(c.getType());
      } else {
        type = verbalizer.verbalize(c.getList());
      }
      return name + type + ")";
    } else if (condition instanceof BeforeCondition) {
      BeforeCondition c = (BeforeCondition) condition;
      String type = "";
      if (c.getType() != null) {
        type = verbalizer.verbalize(c.getType());
      } else {
        type = verbalizer.verbalize(c.getList());
      }
      return name + type + ")";
    } else if (condition instanceof AfterCondition) {
      AfterCondition c = (AfterCondition) condition;
      String type = "";
      if (c.getType() != null) {
        type = verbalizer.verbalize(c.getType());
      } else {
        type = verbalizer.verbalize(c.getList());
      }
      return name + type + ")";
    } else if (condition instanceof StartsWithCondition) {
      StartsWithCondition c = (StartsWithCondition) condition;
      String arg = "";
      if (c.getType() != null) {
        arg = verbalizer.verbalize(c.getType());
      } else {
        arg = verbalizer.verbalize(c.getList());
      }
      return name + arg + ")";
    } else if (condition instanceof EndsWithCondition) {
      EndsWithCondition c = (EndsWithCondition) condition;
      String type = "";
      if (c.getType() != null) {
        type = verbalizer.verbalize(c.getType());
      } else {
        type = verbalizer.verbalize(c.getList());
      }
      return name + type + ")";
    } else if (condition instanceof SizeCondition) {
      SizeCondition c = (SizeCondition) condition;
      NumberExpression minE = c.getMinExpr();
      String min = verbalizeMin(minE, Integer.MIN_VALUE);
      NumberExpression maxE = c.getMaxExpr();
      String max = verbalizeMax(maxE, Integer.MAX_VALUE);
      String var = c.getVarExpr() == null ? "" : ", " + c.getVarExpr();
      ListExpression<?> listExpr = c.getListExpr();
      if (listExpr == null) {
        return name + min + max + var + ")";
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.