Examples of ShiftAction


Examples of net.sourceforge.chaperon.build.ShiftAction

          {
            productionnode.linenumber = locator.getLineNumber();
            productionnode.columnnumber = locator.getColumnNumber();
          }

          ShiftAction shiftaction = ancestor.state.getShiftAction(productionnode.symbol);

          if (shiftaction!=null)
          {
            StateNode newstatenode = getStateNode(current, shiftaction.state, ancestor);

            if (newstatenode==null)
            {
              System.out.println("new state node: new state="+automaton.indexOf(shiftaction.state)+
                                 " ancestor state="+automaton.indexOf(ancestor.state));
              newstatenode = new StateNode(shiftaction.state, ancestor, productionnode);
              current.push(newstatenode);
            }
            else
            {
              System.out.println("merging state node");

              ProductionNode oldproductionnode = (ProductionNode)newstatenode.treenode;

              if (grammar.getPriority(oldproductionnode.production)>grammar.getPriority(production))
              {
                System.out.println("priority("+production+") < priority("+
                                   oldproductionnode.production+")");
                newstatenode.treenode = productionnode;
              }
              else
                System.out.println("priority("+production+") >= priority("+
                                   oldproductionnode.production+")");
            }
          }
        }
      }
    }

    Stack dummy = next;
    next = current;
    current = dummy;

    System.out.println("Current states");

    for (int i = 0; i<current.size(); i++)
      System.out.println(current.get(i));

    System.out.println();

    /* ==================================== Shift  =================================== */
    TokenNode tokennode = new TokenNode(symbol, text);

    if (locator!=null)
    {
      tokennode.linenumber = locator.getLineNumber();
      tokennode.columnnumber = locator.getColumnNumber();
    }

    while (!current.isEmpty())
    {
      StateNode statenode = (StateNode)current.pop();

      ShiftAction shiftaction = statenode.state.getShiftAction(symbol);

      if (shiftaction!=null)
      {
        if ((log!=null) && (log.isDebugEnabled()))
          log.debug(
View Full Code Here

Examples of net.sourceforge.chaperon.build.ShiftAction

            ancestor = ancestor.ancestor;
          }

          productionnode.descendants = descendants;

          ShiftAction shiftaction = ancestor.state.getShiftAction(productionnode.symbol);

          //System.out.println("current state:\n"+ancestor.state+"\ntransition for "+productionnode.symbol+" = "+shiftaction);
          if ((automaton.getState(0)==ancestor.state) &&
              (productionnode.symbol.equals(grammar.getStartSymbol())))
          {
View Full Code Here

Examples of org.allspice.parser.parsetable.ShiftAction

      else {
        String a = item.core.r.rhs.get(item.core.pos) ;
        if (!g.rules.containsKey(a)) {
          LR1State dest = lalr1gotos.get(a) ;
          if (dest != null) {
            setAction(pt,st,a,new ShiftAction(dest.state));
          }           
        }
      }
    }
  }
View Full Code Here

Examples of org.apache.uima.ruta.action.ShiftAction

    a = new SetFeatureAction(stringExpr, typeExpr1);
    s = v.verbalize(a);
    assertEquals("SETFEATURE(\"string\", Type1)", s);

    // SHIFT
    a = new ShiftAction(typeExpr1, indexes);
    s = v.verbalize(a);
    assertEquals("SHIFT(Type1, 4, numVar)", s);

    // TRANSFER
    a = new TransferAction(typeExpr1);
View Full Code Here

Examples of org.apache.uima.ruta.action.ShiftAction

      if (a.getList() != null && !a.getList().isEmpty()) {
        string = ", " + verbalizer.verbalizeExpressionList(a.getList());
      }
      return name + verbalizer.verbalize(a.getType()) + string + ")";
    } else if (action instanceof ShiftAction) {
      ShiftAction a = (ShiftAction) action;
      String string = "";
      if (a.getList() != null && !a.getList().isEmpty()) {
        string = ", " + verbalizer.verbalizeExpressionList(a.getList());
      }
      return name + verbalizer.verbalize(a.getType()) + string + ")";
    } else if (action instanceof MarkAction) {
      MarkAction a = (MarkAction) action;
      if (a.getScore() != null) {
        String score = verbalizer.verbalize(a.getScore());
        if (!"".equals(score)) {
          score += ", ";
        }
        String string = "";
        if (a.getList() != null && !a.getList().isEmpty()) {
          string = ", " + verbalizer.verbalizeExpressionList(a.getList());
        }
        return name + score + verbalizer.verbalize(a.getType()) + string + ")";
      } else {
        String string = "";
        if (a.getList() != null && !a.getList().isEmpty()) {
          string = ", " + verbalizer.verbalizeExpressionList(a.getList());
        }
        return name + verbalizer.verbalize(a.getType()) + string + ")";
      }
    } else if (action instanceof MarkFastAction) {
      MarkFastAction a = (MarkFastAction) action;
      String list = "";
      if (a.getList() != null) {
        list = verbalizer.verbalize(a.getList());
      } else if (a.getStringList() != null) {
        list = verbalizer.verbalize(a.getStringList());
      }
      return name + verbalizer.verbalize(a.getType()) + ", " + list + ", "
              + verbalizer.verbalize(a.getIgnore()) + ", "
              + verbalizer.verbalize(a.getIgnoreLength()) + ", "
              + verbalizer.verbalize(a.getIgnoreWS()) + ")";
    } else if (action instanceof MarkLastAction) {
      MarkLastAction a = (MarkLastAction) action;
      return name + verbalizer.verbalize(a.getType()) + ")";
    } else if (action instanceof MarkFirstAction) {
      MarkFirstAction a = (MarkFirstAction) action;
      return name + verbalizer.verbalize(a.getType()) + ")";
    } else if (action instanceof ReplaceAction) {
      ReplaceAction a = (ReplaceAction) action;
      return name + verbalizer.verbalize(a.getReplacement()) + ")";
    } else if (action instanceof RetainTypeAction) {
      RetainTypeAction a = (RetainTypeAction) action;
      return a.getList().isEmpty() ? "RETAINTYPE" : "RETAINTYPE("
              + verbalizer.verbalizeExpressionList(a.getList()) + ")";
    } else if (action instanceof SetFeatureAction) {
      SetFeatureAction a = (SetFeatureAction) action;
      String e1 = verbalizer.verbalize(a.getFeatureStringExpression());
      String e2 = verbalizer.verbalize(a.getExpr());
      return name + e1 + ", " + e2 + ")";
    } else if (action instanceof GetFeatureAction) {
      GetFeatureAction a = (GetFeatureAction) action;

      return name + verbalizer.verbalize(a.getFeatureStringExpression()) + ", " + a.getVariable()
              + ")";
    } else if (action instanceof UnmarkAction) {
      UnmarkAction a = (UnmarkAction) action;
      if (a.getAllAnchor() == null) {
        if (a.getList() == null) {
          return name + verbalizer.verbalize(a.getType()) + ")";
        } else {
          return name + verbalizer.verbalize(a.getType()) + ", "
                  + verbalizer.verbalizeExpressionList(a.getList()) + ")";
        }
      } else {
        return name + verbalizer.verbalize(a.getType()) + ", "
                + verbalizer.verbalizeExpressionList(a.getList()) + ", "
                + verbalizer.verbalize(a.getAllAnchor()) + ")";
      }
    } else if (action instanceof TransferAction) {
      TransferAction a = (TransferAction) action;
      return name + verbalizer.verbalize(a.getType()) + ")";
    } else if (action instanceof TrieAction) {
      TrieAction a = (TrieAction) action;
      String map = "";
      if (a.getMap() != null) {
        for (IStringExpression each : a.getMap().keySet()) {
          map += verbalizer.verbalize(each);
          map += " = ";
          map += verbalizer.verbalize(a.getMap().get(each));
          map += ", ";
        }
      }
      return name + map + verbalizer.verbalize(a.getList()) + ", "
              + verbalizer.verbalize(a.getIgnoreCase()) + ", "
              + verbalizer.verbalize(a.getIgnoreLength()) + ", "
              + verbalizer.verbalize(a.getEdit()) + ", " + verbalizer.verbalize(a.getDistance())
              + ", " + verbalizer.verbalize(a.getIgnoreChar()) + ")";
    } else if (action instanceof AddAction) {
      AddAction a = (AddAction) action;
      return name + a.getListExpr() + ", " + verbalizer.verbalizeExpressionList(a.getElements())
              + ")";
    } else if (action instanceof RemoveAction) {
      RemoveAction a = (RemoveAction) action;
      return name + a.getListExpr() + ", " + verbalizer.verbalizeExpressionList(a.getElements())
              + ")";
    } else if (action instanceof RemoveAction) {
      RemoveAction a = (RemoveAction) action;
      return name + a.getListExpr() + ")";
    } else if (action instanceof MergeAction) {
      MergeAction a = (MergeAction) action;
      return name + verbalizer.verbalize(a.getUnion()) + ", " + a.getTarget() + ", "
              + verbalizer.verbalizeExpressionList(a.getLists()) + ")";
    } else if (action instanceof GetAction) {
      GetAction a = (GetAction) action;
      return name + verbalizer.verbalize(a.getListExpr()) + ", " + a.getVar() + ", "
              + verbalizer.verbalize(a.getOpExpr()) + ")";
    } else if (action instanceof ClearAction) {
      ClearAction a = (ClearAction) action;
      return name + a.getList() + ")";
    } else if (action instanceof ConfigureAction) {
      ConfigureAction a = (ConfigureAction) action;

      String map = "";
      if (a.getParameterMap() != null) {
        map += ", ";
        for (IStringExpression each : a.getParameterMap().keySet()) {
          map += verbalizer.verbalize(each);
          map += " = ";
          map += verbalizer.verbalize(a.getParameterMap().get(each));
          map += ", ";
        }
      }
      map = map.substring(0, map.length() - 2);
      return name + a.getNamespace() + map + ")";
    } else if (action instanceof DynamicAnchoringAction) {
      DynamicAnchoringAction a = (DynamicAnchoringAction) action;

      IBooleanExpression active = a.getActive();
      INumberExpression panelty = a.getPanelty();
      INumberExpression 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 GreedyAnchoringAction) {
      GreedyAnchoringAction a = (GreedyAnchoringAction) action;
      IBooleanExpression active = a.getGreedyRuleElement();
      IBooleanExpression active2 = a.getGreedyRule();
      String pa = verbalizer.verbalize(active);
      String pa2 = "";
      if (active2 != null) {
        pa2 = ", " + verbalizer.verbalize(active2);
      }
      return name + pa + pa2 + ")";
    } 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();
      INumberExpression indexExpr = a.getIndexExpr();
      WordTableExpression tableExpr = a.getTableExpr();
      Map<IStringExpression, INumberExpression> featureMap = a.getFeatureMap();
      IBooleanExpression ignoreCase = a.getIgnoreCase();
      INumberExpression ignoreLength = a.getIgnoreLength();
      IStringExpression ignoreChar = a.getIgnoreChar();
      INumberExpression maxIgnoreChar = a.getMaxIgnoreChar();

      String type = verbalizer.verbalize(typeExpr);
      String index = verbalizer.verbalize(indexExpr);
      String table = verbalizer.verbalize(tableExpr);
      String map = "";
      if (featureMap != null) {
        map += ", ";
        for (IStringExpression each : featureMap.keySet()) {
          map += verbalizer.verbalize(each);
          map += " = ";
          map += verbalizer.verbalize(featureMap.get(each));
          map += ", ";
        }
      }
      String icase = ignoreCase == null ? "" : ", " + verbalizer.verbalize(ignoreCase);
      String ilength = ignoreCase == null ? "" : ", " + verbalizer.verbalize(ignoreLength);
      String ichar = ignoreCase == null ? "" : ", " + verbalizer.verbalize(ignoreChar);
      String mic = ignoreCase == null ? "" : ", " + verbalizer.verbalize(maxIgnoreChar);

      return name + type + ", " + index + ", " + table + map + icase + ilength + ichar + mic + ")";
    } else if (action instanceof MatchedTextAction) {
      MatchedTextAction a = (MatchedTextAction) action;
      String var = a.getVar();
      List<INumberExpression> list = a.getList();
      String indexes = list == null ? "" : ", " + verbalizer.verbalizeExpressionList(list);
      return name + var + indexes + ")";
    } else if (action instanceof RemoveDuplicateAction) {
      RemoveDuplicateAction a = (RemoveDuplicateAction) action;
      String listExpr = a.getListExpr();
      return name + listExpr + ")";
    } else if (action instanceof UnmarkAllAction) {
      UnmarkAllAction a = (UnmarkAllAction) action;
      String verbalize = verbalizer.verbalize(a.getType());
      String but = a.getList() == null ? "" : ", " + verbalizer.verbalize(a.getList());
      return name + verbalize + but + ")";
    } else if (action instanceof TrimAction) {
      TrimAction a = (TrimAction) action;
      TypeListExpression typeList = a.getTypeList();
      String verbalize = "";
      if (typeList != null) {
        verbalize = verbalizer.verbalize(typeList);
      } else if (a.getTypes() != null) {
        verbalize = verbalizer.verbalizeExpressionList(a.getTypes());
      }
      return name + verbalize + ")";
    } else if (action instanceof ImplicitMarkAction) {
      ImplicitMarkAction a = (ImplicitMarkAction) action;
      return verbalizer.verbalize(a.getType());
    } else if (action instanceof ImplicitFeatureAction) {
      ImplicitFeatureAction a = (ImplicitFeatureAction) action;
      return verbalizer.verbalize(a.getExpr());
    }

    return action.getClass().getSimpleName();
  }
View Full Code Here

Examples of org.apache.uima.ruta.action.ShiftAction

      if (a.getList() != null && !a.getList().isEmpty()) {
        string = ", " + verbalizer.verbalizeExpressionList(a.getList());
      }
      return name + verbalizer.verbalize(a.getType()) + string + ")";
    } else if (action instanceof ShiftAction) {
      ShiftAction a = (ShiftAction) action;
      String string = "";
      if (a.getList() != null && !a.getList().isEmpty()) {
        string = ", " + verbalizer.verbalizeExpressionList(a.getList());
      }
      return name + verbalizer.verbalize(a.getType()) + string + ")";
    } else if (action instanceof MarkAction) {
      MarkAction a = (MarkAction) action;
      if (a.getScore() != null) {
        String score = verbalizer.verbalize(a.getScore());
        if (!"".equals(score)) {
          score += ", ";
        }
        String string = "";
        if (a.getList() != null && !a.getList().isEmpty()) {
          string = ", " + verbalizer.verbalizeExpressionList(a.getList());
        }
        return name + score + verbalizer.verbalize(a.getType()) + string + ")";
      } else {
        String string = "";
        if (a.getList() != null && !a.getList().isEmpty()) {
          string = ", " + verbalizer.verbalizeExpressionList(a.getList());
        }
        return name + verbalizer.verbalize(a.getType()) + string + ")";
      }
    } else if (action instanceof MarkFastAction) {
      MarkFastAction a = (MarkFastAction) action;
      String list = "";
      if (a.getList() != null) {
        list = verbalizer.verbalize(a.getList());
      } else if (a.getStringList() != null) {
        list = verbalizer.verbalize(a.getStringList());
      }
      return name + verbalizer.verbalize(a.getType()) + ", " + list + ", "
              + verbalizer.verbalize(a.getIgnore()) + ", "
              + verbalizer.verbalize(a.getIgnoreLength()) + ", "
              + verbalizer.verbalize(a.getIgnoreWS()) + ")";
    } else if (action instanceof MarkLastAction) {
      MarkLastAction a = (MarkLastAction) action;
      return name + verbalizer.verbalize(a.getType()) + ")";
    } else if (action instanceof ReplaceAction) {
      ReplaceAction a = (ReplaceAction) action;
      return name + verbalizer.verbalize(a.getReplacement()) + ")";
    } else if (action instanceof RetainTypeAction) {
      RetainTypeAction a = (RetainTypeAction) action;
      return a.getList().isEmpty() ? "RETAINTYPE" : "RETAINTYPE("
              + verbalizer.verbalizeExpressionList(a.getList()) + ")";
    } else if (action instanceof SetFeatureAction) {
      SetFeatureAction a = (SetFeatureAction) action;
      String e1 = verbalizer.verbalize(a.getFeatureStringExpression());
      String e2 = "";
      if (a.getBooleanExpr() != null) {
        e2 = verbalizer.verbalize(a.getBooleanExpr());
      } else if (a.getNumberExpr() != null) {
        e2 = verbalizer.verbalize(a.getNumberExpr());
      } else if (a.getStringExpr() != null) {
        e2 = verbalizer.verbalize(a.getStringExpr());
      } else if (a.getTypeExpr() != null) {
        e2 = verbalizer.verbalize(a.getTypeExpr());
      }
      return name + e1 + ", " + e2 + ")";
    } else if (action instanceof GetFeatureAction) {
      GetFeatureAction a = (GetFeatureAction) action;

      return name + verbalizer.verbalize(a.getFeatureStringExpression()) + ", " + a.getVariable()
              + ")";
    } else if (action instanceof UnmarkAction) {
      UnmarkAction a = (UnmarkAction) action;
      if (a.getAllAnchor() == null) {
        if (a.getList() == null) {
          return name + verbalizer.verbalize(a.getType()) + ")";
        } else {
          return name + verbalizer.verbalize(a.getType()) + ", "
                  + verbalizer.verbalizeExpressionList(a.getList()) + ")";
        }
      } else {
        return name + verbalizer.verbalize(a.getType()) + ", "
                + verbalizer.verbalizeExpressionList(a.getList()) + ", "
                + verbalizer.verbalize(a.getAllAnchor()) + ")";
      }
    } else if (action instanceof TransferAction) {
      TransferAction a = (TransferAction) action;
      return name + verbalizer.verbalize(a.getType()) + ")";
    } else if (action instanceof TrieAction) {
      TrieAction a = (TrieAction) action;
      String map = "";
      if (a.getMap() != null) {
        for (StringExpression each : a.getMap().keySet()) {
          map += verbalizer.verbalize(each);
          map += " = ";
          map += verbalizer.verbalize(a.getMap().get(each));
          map += ", ";
        }
      }
      return name + map + verbalizer.verbalize(a.getList()) + ", "
              + verbalizer.verbalize(a.getIgnoreCase()) + ", "
              + verbalizer.verbalize(a.getIgnoreLength()) + ", "
              + verbalizer.verbalize(a.getEdit()) + ", " + verbalizer.verbalize(a.getDistance())
              + ", " + verbalizer.verbalize(a.getIgnoreChar()) + ")";
    } else if (action instanceof AddAction) {
      AddAction a = (AddAction) action;
      return name + a.getListExpr() + ", " + verbalizer.verbalizeExpressionList(a.getElements())
              + ")";
    } else if (action instanceof RemoveAction) {
      RemoveAction a = (RemoveAction) action;
      return name + a.getListExpr() + ", " + verbalizer.verbalizeExpressionList(a.getElements())
              + ")";
    } else if (action instanceof RemoveAction) {
      RemoveAction a = (RemoveAction) action;
      return name + a.getListExpr() + ")";
    } else if (action instanceof MergeAction) {
      MergeAction a = (MergeAction) action;
      return name + verbalizer.verbalize(a.getUnion()) + ", " + a.getTarget() + ", "
              + verbalizer.verbalizeExpressionList(a.getLists()) + ")";
    } else if (action instanceof GetAction) {
      GetAction a = (GetAction) action;
      return name + verbalizer.verbalize(a.getListExpr()) + ", " + a.getVar() + ", "
              + verbalizer.verbalize(a.getOpExpr()) + ")";
    } else if (action instanceof ClearAction) {
      ClearAction a = (ClearAction) action;
      return name + a.getList() + ")";
    } else if (action instanceof ConfigureAction) {
      ConfigureAction a = (ConfigureAction) action;

      String map = "";
      if (a.getParameterMap() != null) {
        map += ", ";
        for (StringExpression each : a.getParameterMap().keySet()) {
          map += verbalizer.verbalize(each);
          map += " = ";
          map += verbalizer.verbalize(a.getParameterMap().get(each));
          map += ", ";
        }
      }
      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);
      String index = verbalizer.verbalize(indexExpr);
      String table = verbalizer.verbalize(tableExpr);
      String map = "";
      if (featureMap != null) {
        map += ", ";
        for (StringExpression each : featureMap.keySet()) {
          map += verbalizer.verbalize(each);
          map += " = ";
          map += verbalizer.verbalize(featureMap.get(each));
          map += ", ";
        }
      }
      String icase = ignoreCase == null ? "" : ", " + verbalizer.verbalize(ignoreCase);
      String ilength = ignoreCase == null ? "" : ", " + verbalizer.verbalize(ignoreLength);
      String ichar = ignoreCase == null ? "" : ", " + verbalizer.verbalize(ignoreChar);
      String mic = ignoreCase == null ? "" : ", " + verbalizer.verbalize(maxIgnoreChar);

      return name + type + ", " + index + ", " + table + map + icase + ilength + ichar + mic + ")";
    } else if (action instanceof MatchedTextAction) {
      MatchedTextAction a = (MatchedTextAction) action;
      String var = a.getVar();
      List<NumberExpression> list = a.getList();
      String indexes = list == null ? "" : ", " + verbalizer.verbalizeExpressionList(list);
      return name + var + indexes + ")";
    } else if (action instanceof RemoveDuplicateAction) {
      RemoveDuplicateAction a = (RemoveDuplicateAction) action;
      String listExpr = a.getListExpr();
      return name + listExpr + ")";
    } else if (action instanceof UnmarkAllAction) {
      UnmarkAllAction a = (UnmarkAllAction) action;
      String verbalize = verbalizer.verbalize(a.getType());
      String but = a.getList() == null ? "" : ", " + verbalizer.verbalize(a.getList());
      return name + verbalize + but + ")";
    }

    return action.getClass().getSimpleName();
  }
View Full Code Here

Examples of org.apache.uima.ruta.action.ShiftAction

    a = new SetFeatureAction(stringExpr, typeExpr1);
    s = v.verbalize(a);
    assertEquals("SETFEATURE(\"string\", Type1)", s);

    // SHIFT
    a = new ShiftAction(typeExpr1, indexes);
    s = v.verbalize(a);
    assertEquals("SHIFT(Type1, 4, numVar)", s);

    // TRANSFER
    a = new TransferAction(typeExpr1);
View Full Code Here

Examples of org.apache.uima.ruta.action.ShiftAction

      if (a.getList() != null && !a.getList().isEmpty()) {
        string = ", " + verbalizer.verbalizeExpressionList(a.getList());
      }
      return name + verbalizer.verbalize(a.getType()) + string + ")";
    } else if (action instanceof ShiftAction) {
      ShiftAction a = (ShiftAction) action;
      String string = "";
      if (a.getList() != null && !a.getList().isEmpty()) {
        string = ", " + verbalizer.verbalizeExpressionList(a.getList());
      }
      return name + verbalizer.verbalize(a.getType()) + string + ")";
    } else if (action instanceof MarkAction) {
      MarkAction a = (MarkAction) action;
      if (a.getScore() != null) {
        String score = verbalizer.verbalize(a.getScore());
        if (!"".equals(score)) {
          score += ", ";
        }
        String string = "";
        if (a.getList() != null && !a.getList().isEmpty()) {
          string = ", " + verbalizer.verbalizeExpressionList(a.getList());
        }
        return name + score + verbalizer.verbalize(a.getType()) + string + ")";
      } else {
        String string = "";
        if (a.getList() != null && !a.getList().isEmpty()) {
          string = ", " + verbalizer.verbalizeExpressionList(a.getList());
        }
        return name + verbalizer.verbalize(a.getType()) + string + ")";
      }
    } else if (action instanceof MarkFastAction) {
      MarkFastAction a = (MarkFastAction) action;
      String list = "";
      if (a.getList() != null) {
        list = verbalizer.verbalize(a.getList());
      } else if (a.getStringList() != null) {
        list = verbalizer.verbalize(a.getStringList());
      }
      return name + verbalizer.verbalize(a.getType()) + ", " + list + ", "
              + verbalizer.verbalize(a.getIgnore()) + ", "
              + verbalizer.verbalize(a.getIgnoreLength()) + ", "
              + verbalizer.verbalize(a.getIgnoreWS()) + ")";
    } else if (action instanceof MarkLastAction) {
      MarkLastAction a = (MarkLastAction) action;
      return name + verbalizer.verbalize(a.getType()) + ")";
    } else if (action instanceof MarkFirstAction) {
      MarkFirstAction a = (MarkFirstAction) action;
      return name + verbalizer.verbalize(a.getType()) + ")";
    } else if (action instanceof ReplaceAction) {
      ReplaceAction a = (ReplaceAction) action;
      return name + verbalizer.verbalize(a.getReplacement()) + ")";
    } else if (action instanceof RetainTypeAction) {
      RetainTypeAction a = (RetainTypeAction) action;
      return a.getList().isEmpty() ? "RETAINTYPE" : "RETAINTYPE("
              + verbalizer.verbalizeExpressionList(a.getList()) + ")";
    } else if (action instanceof SetFeatureAction) {
      SetFeatureAction a = (SetFeatureAction) action;
      String e1 = verbalizer.verbalize(a.getFeatureStringExpression());
      String e2 = "";
      if (a.getBooleanExpr() != null) {
        e2 = verbalizer.verbalize(a.getBooleanExpr());
      } else if (a.getNumberExpr() != null) {
        e2 = verbalizer.verbalize(a.getNumberExpr());
      } else if (a.getStringExpr() != null) {
        e2 = verbalizer.verbalize(a.getStringExpr());
      } else if (a.getTypeExpr() != null) {
        e2 = verbalizer.verbalize(a.getTypeExpr());
      }
      return name + e1 + ", " + e2 + ")";
    } else if (action instanceof GetFeatureAction) {
      GetFeatureAction a = (GetFeatureAction) action;

      return name + verbalizer.verbalize(a.getFeatureStringExpression()) + ", " + a.getVariable()
              + ")";
    } else if (action instanceof UnmarkAction) {
      UnmarkAction a = (UnmarkAction) action;
      if (a.getAllAnchor() == null) {
        if (a.getList() == null) {
          return name + verbalizer.verbalize(a.getType()) + ")";
        } else {
          return name + verbalizer.verbalize(a.getType()) + ", "
                  + verbalizer.verbalizeExpressionList(a.getList()) + ")";
        }
      } else {
        return name + verbalizer.verbalize(a.getType()) + ", "
                + verbalizer.verbalizeExpressionList(a.getList()) + ", "
                + verbalizer.verbalize(a.getAllAnchor()) + ")";
      }
    } else if (action instanceof TransferAction) {
      TransferAction a = (TransferAction) action;
      return name + verbalizer.verbalize(a.getType()) + ")";
    } else if (action instanceof TrieAction) {
      TrieAction a = (TrieAction) action;
      String map = "";
      if (a.getMap() != null) {
        for (StringExpression each : a.getMap().keySet()) {
          map += verbalizer.verbalize(each);
          map += " = ";
          map += verbalizer.verbalize(a.getMap().get(each));
          map += ", ";
        }
      }
      return name + map + verbalizer.verbalize(a.getList()) + ", "
              + verbalizer.verbalize(a.getIgnoreCase()) + ", "
              + verbalizer.verbalize(a.getIgnoreLength()) + ", "
              + verbalizer.verbalize(a.getEdit()) + ", " + verbalizer.verbalize(a.getDistance())
              + ", " + verbalizer.verbalize(a.getIgnoreChar()) + ")";
    } else if (action instanceof AddAction) {
      AddAction a = (AddAction) action;
      return name + a.getListExpr() + ", " + verbalizer.verbalizeExpressionList(a.getElements())
              + ")";
    } else if (action instanceof RemoveAction) {
      RemoveAction a = (RemoveAction) action;
      return name + a.getListExpr() + ", " + verbalizer.verbalizeExpressionList(a.getElements())
              + ")";
    } else if (action instanceof RemoveAction) {
      RemoveAction a = (RemoveAction) action;
      return name + a.getListExpr() + ")";
    } else if (action instanceof MergeAction) {
      MergeAction a = (MergeAction) action;
      return name + verbalizer.verbalize(a.getUnion()) + ", " + a.getTarget() + ", "
              + verbalizer.verbalizeExpressionList(a.getLists()) + ")";
    } else if (action instanceof GetAction) {
      GetAction a = (GetAction) action;
      return name + verbalizer.verbalize(a.getListExpr()) + ", " + a.getVar() + ", "
              + verbalizer.verbalize(a.getOpExpr()) + ")";
    } else if (action instanceof ClearAction) {
      ClearAction a = (ClearAction) action;
      return name + a.getList() + ")";
    } else if (action instanceof ConfigureAction) {
      ConfigureAction a = (ConfigureAction) action;

      String map = "";
      if (a.getParameterMap() != null) {
        map += ", ";
        for (StringExpression each : a.getParameterMap().keySet()) {
          map += verbalizer.verbalize(each);
          map += " = ";
          map += verbalizer.verbalize(a.getParameterMap().get(each));
          map += ", ";
        }
      }
      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);
      String index = verbalizer.verbalize(indexExpr);
      String table = verbalizer.verbalize(tableExpr);
      String map = "";
      if (featureMap != null) {
        map += ", ";
        for (StringExpression each : featureMap.keySet()) {
          map += verbalizer.verbalize(each);
          map += " = ";
          map += verbalizer.verbalize(featureMap.get(each));
          map += ", ";
        }
      }
      String icase = ignoreCase == null ? "" : ", " + verbalizer.verbalize(ignoreCase);
      String ilength = ignoreCase == null ? "" : ", " + verbalizer.verbalize(ignoreLength);
      String ichar = ignoreCase == null ? "" : ", " + verbalizer.verbalize(ignoreChar);
      String mic = ignoreCase == null ? "" : ", " + verbalizer.verbalize(maxIgnoreChar);

      return name + type + ", " + index + ", " + table + map + icase + ilength + ichar + mic + ")";
    } else if (action instanceof MatchedTextAction) {
      MatchedTextAction a = (MatchedTextAction) action;
      String var = a.getVar();
      List<NumberExpression> list = a.getList();
      String indexes = list == null ? "" : ", " + verbalizer.verbalizeExpressionList(list);
      return name + var + indexes + ")";
    } else if (action instanceof RemoveDuplicateAction) {
      RemoveDuplicateAction a = (RemoveDuplicateAction) action;
      String listExpr = a.getListExpr();
      return name + listExpr + ")";
    } else if (action instanceof UnmarkAllAction) {
      UnmarkAllAction a = (UnmarkAllAction) action;
      String verbalize = verbalizer.verbalize(a.getType());
      String but = a.getList() == null ? "" : ", " + verbalizer.verbalize(a.getList());
      return name + verbalize + but + ")";
    } else if (action instanceof TrimAction) {
      TrimAction a = (TrimAction) action;
      TypeListExpression typeList = a.getTypeList();
      String verbalize = "";
      if(typeList != null) {
        verbalize = verbalizer.verbalize(typeList);
      } else if(a.getTypes() != null) {
        verbalize = verbalizer.verbalizeExpressionList(a.getTypes());
      }
      return name + verbalize + ")";
    } else if (action instanceof ImplicitMarkAction) {
      ImplicitMarkAction a = (ImplicitMarkAction) action;
      return verbalizer.verbalize(a.getType());
    } else if (action instanceof ImplicitFeatureAction) {
      ImplicitFeatureAction a = (ImplicitFeatureAction) action;
      return verbalizer.verbalize(a.getExpr());
    }

    return action.getClass().getSimpleName();
  }
View Full Code Here

Examples of org.apache.uima.ruta.action.ShiftAction

    a = new SetFeatureAction(stringExpr, typeExpr1);
    s = v.verbalize(a);
    assertEquals("SETFEATURE(\"string\", Type1)", s);

    // SHIFT
    a = new ShiftAction(typeExpr1, indexes);
    s = v.verbalize(a);
    assertEquals("SHIFT(Type1, 4, numVar)", s);

    // TRANSFER
    a = new TransferAction(typeExpr1);
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.