Package org.apache.uima.ruta.expression.bool

Examples of org.apache.uima.ruta.expression.bool.BooleanExpression


      map = map.substring(0, map.length() - 2);
      return name + a.getNamespace() + map + ")";
    } else if (action instanceof DynamicAnchoringAction) {
      DynamicAnchoringAction a = (DynamicAnchoringAction) action;

      BooleanExpression active = a.getActive();
      NumberExpression panelty = a.getPanelty();
      NumberExpression factor = a.getFactor();

      String pa = verbalizer.verbalize(active);
      String pp = panelty == null ? "" : ", " + verbalizer.verbalize(panelty);
      String pf = factor == null ? "" : ", " + verbalizer.verbalize(factor);
      return name + pa + pp + pf + ")";
    } else if (action instanceof GetListAction) {
      GetListAction a = (GetListAction) action;
      String var = a.getVar();
      String op = verbalizer.verbalize(a.getOpExpr());
      return name + var + ", " + op + ")";
    } else if (action instanceof MarkTableAction) {
      MarkTableAction a = (MarkTableAction) action;
      TypeExpression typeExpr = a.getTypeExpr();
      NumberExpression indexExpr = a.getIndexExpr();
      WordTableExpression tableExpr = a.getTableExpr();
      Map<StringExpression, NumberExpression> featureMap = a.getFeatureMap();
      BooleanExpression ignoreCase = a.getIgnoreCase();
      NumberExpression ignoreLength = a.getIgnoreLength();
      StringExpression ignoreChar = a.getIgnoreChar();
      NumberExpression maxIgnoreChar = a.getMaxIgnoreChar();

      String type = verbalizer.verbalize(typeExpr);
View Full Code Here


              && count <= max.getIntegerValue(element.getParent());
      return new EvaluatedCondition(this, value);
    } else {
      int count = 0;
      if (arg instanceof BooleanExpression && list instanceof BooleanListExpression) {
        BooleanExpression e = (BooleanExpression) arg;
        BooleanListExpression le = (BooleanListExpression) list;
        boolean v = e.getBooleanValue(element.getParent());
        List<Boolean> l = new ArrayList<Boolean>(le.getList(element.getParent()));
        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());
        List<Number> l = new ArrayList<Number>(le.getList(element.getParent()));
        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());
        List<String> l = new ArrayList<String>(le.getList(element.getParent()));
        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()));
        while (l.remove(v)) {
          count++;
        }
      }
View Full Code Here

        }
      }
    } else {
      totalCount = argList.getList(element.getParent()).size();
      if (arg instanceof BooleanExpression && argList instanceof BooleanListExpression) {
        BooleanExpression e = (BooleanExpression) arg;
        BooleanListExpression le = (BooleanListExpression) argList;
        boolean v = e.getBooleanValue(element.getParent());
        List<Boolean> l = new ArrayList<Boolean>(le.getList(element.getParent()));
        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());
        List<Number> l = new ArrayList<Number>(le.getList(element.getParent()));
        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());
        List<String> l = new ArrayList<String>(le.getList(element.getParent()));
        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()));
        while (l.remove(v)) {
          basicCount++;
        }
      }
View Full Code Here

    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);
    WordListExpression wordListExpr = new ReferenceWordListExpression(var);
View Full Code Here

    s = v.verbalize(numExpr6);
    assertEquals("4.9 * 4 + numVar", s);
   
   
   
    BooleanExpression boolExpr1 = new SimpleBooleanExpression(true);
    BooleanExpression boolExpr2 = new SimpleBooleanExpression(false);
    BooleanExpression boolExpr3 = new ReferenceBooleanExpression(var);
    BooleanExpression boolExpr4 = new BooleanNumberExpression(numExpr1, "==", numExpr2);
    BooleanExpression boolExpr5 = new BooleanNumberExpression(numExpr1, "!=", numExpr2);
    BooleanExpression boolExpr6 = new BooleanNumberExpression(numExpr1, "<=", numExpr2);
    BooleanExpression boolExpr7 = new BooleanNumberExpression(numExpr1, ">=", numExpr2);
    BooleanExpression boolExpr8 = new BooleanNumberExpression(numExpr1, "<", numExpr2);
    BooleanExpression boolExpr9 = new BooleanNumberExpression(numExpr1, ">", numExpr2);
    BooleanExpression boolExpr10 = new BooleanTypeExpression(typeExpr1, "==", typeExpr2);
    BooleanExpression boolExpr11 = new BooleanTypeExpression(typeExpr1, "!=", typeExpr2);
   
    s = v.verbalize(boolExpr1);
    assertEquals("true", s);
    s = v.verbalize(boolExpr2);
    assertEquals("false", s);
View Full Code Here

    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);
    AbstractRutaCondition c = null;
View Full Code Here

            BooleanListExpression ble = (BooleanListExpression) value;
            List<Boolean> list = ble.getList(element.getParent());
            targetEngine.setConfigParameterValue(stringValue, list.toArray());
          } else {
            if (value instanceof BooleanExpression) {
              BooleanExpression be = (BooleanExpression) value;
              Boolean b = be.getBooleanValue(element.getParent());
              targetEngine.setConfigParameterValue(stringValue, b);
            }
          }
        }
      }
View Full Code Here

        }
      } else if (clazz.equals(String.class) && value instanceof StringExpression) {
        StringExpression se = (StringExpression) value;
        return se.getStringValue(owner);
      } else if (clazz.equals(Boolean.class) && value instanceof BooleanExpression) {
        BooleanExpression be = (BooleanExpression) value;
        return be.getBooleanValue(owner);
      }
      if (clazz.equals(RutaWordList.class) && value instanceof LiteralWordListExpression) {
        LiteralWordListExpression lle = (LiteralWordListExpression) value;
        String path = lle.getText();
        RutaWordList wordList = getWordList(path);
View Full Code Here

      map = map.substring(0, map.length() - 2);
      return name + a.getNamespace() + map + ")";
    } else if (action instanceof DynamicAnchoringAction) {
      DynamicAnchoringAction a = (DynamicAnchoringAction) action;

      BooleanExpression active = a.getActive();
      NumberExpression panelty = a.getPanelty();
      NumberExpression factor = a.getFactor();

      String pa = verbalizer.verbalize(active);
      String pp = panelty == null ? "" : ", " + verbalizer.verbalize(panelty);
      String pf = factor == null ? "" : ", " + verbalizer.verbalize(factor);
      return name + pa + pp + pf + ")";
    } else if (action instanceof GetListAction) {
      GetListAction a = (GetListAction) action;
      String var = a.getVar();
      String op = verbalizer.verbalize(a.getOpExpr());
      return name + var + ", " + op + ")";
    } else if (action instanceof MarkTableAction) {
      MarkTableAction a = (MarkTableAction) action;
      TypeExpression typeExpr = a.getTypeExpr();
      NumberExpression indexExpr = a.getIndexExpr();
      WordTableExpression tableExpr = a.getTableExpr();
      Map<StringExpression, NumberExpression> featureMap = a.getFeatureMap();
      BooleanExpression ignoreCase = a.getIgnoreCase();
      NumberExpression ignoreLength = a.getIgnoreLength();
      StringExpression ignoreChar = a.getIgnoreChar();
      NumberExpression maxIgnoreChar = a.getMaxIgnoreChar();

      String type = verbalizer.verbalize(typeExpr);
View Full Code Here

          RutaBlock parent) {
    String rn = feature.getRange().getName();
    if (rn.equals(UIMAConstants.TYPE_BOOLEAN)) {
      Boolean v1 = afs.getBooleanValue(feature);
      if (arg instanceof BooleanExpression) {
        BooleanExpression expr = (BooleanExpression) arg;
        Boolean v2 = expr.getBooleanValue(parent, afs, stream);
        return compare(v1, v2);
      }
    } else if (rn.equals(UIMAConstants.TYPE_INTEGER) || rn.equals(UIMAConstants.TYPE_BYTE)
            || rn.equals(UIMAConstants.TYPE_SHORT) || rn.equals(UIMAConstants.TYPE_LONG)) {
      Integer v1 = afs.getIntValue(feature);
      if (arg instanceof NumberExpression) {
        NumberExpression expr = (NumberExpression) arg;
        Integer v2 = expr.getIntegerValue(parent, afs, stream);
        return compare(v1, v2);
      }
    } else if (rn.equals(UIMAConstants.TYPE_DOUBLE)) {
      Double v1 = afs.getDoubleValue(feature);
      if (arg instanceof NumberExpression) {
        NumberExpression expr = (NumberExpression) arg;
        Double v2 = expr.getDoubleValue(parent, afs, stream);
        return compare(v1, v2);
      }
    } else if (rn.equals(UIMAConstants.TYPE_FLOAT)) {
      Float v1 = afs.getFloatValue(feature);
      if (arg instanceof NumberExpression) {
        NumberExpression expr = (NumberExpression) arg;
        Float v2 = expr.getFloatValue(parent, afs, stream);
        return compare(v1, v2);
      }
    } else if (rn.equals(UIMAConstants.TYPE_STRING)) {
      String v1 = afs.getStringValue(feature);
      if (arg instanceof StringExpression) {
        StringExpression expr = (StringExpression) arg;
        String v2 = expr.getStringValue(parent, afs, stream);
        return compare(v1, v2);
      }
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.ruta.expression.bool.BooleanExpression

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.