public String getStringForRuleString()

in ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/whisk/generic/WhiskRuleItem.java [137:215]


  public String getStringForRuleString(TextRulerRule rule, MLRuleItemType type,
          int numberInPattern, int patternSize, int numberInRule, int ruleSize, int slotIndex) {

    String result = "";
    WhiskRule whiskRule = (WhiskRule) rule;
    boolean isMarkingItem = type == MLRuleItemType.FILLER && numberInPattern == 0;
    ArrayList<String> constraints = new ArrayList<String>();

    String anchor = null;

    if (wordConstraint != null) {
      if (wordConstraint.isRegExpConstraint()) {
        anchor = wordConstraint.typeShortName();
        if (!hideRegExp)
          constraints.add("REGEXP(\"" + wordConstraint + "\")");
      } else
        anchor = wordConstraint.toString();
    }

    MLWhiskOtherConstraint anchorConstraint = null;
    if (anchor == null) {
      for (MLWhiskOtherConstraint c : otherConstraints)
        if (c.canBeAnchorConstraint()) {
          anchorConstraint = c;
          break;
        }
    }

    for (MLWhiskOtherConstraint oc : otherConstraints) {
      if (oc != anchorConstraint) {
        if (oc.canBeAnchorConstraint())
          constraints.add("IS(" + oc + ")");
        else
          constraints.add("PARTOF(" + oc + ")");
      }
    }
    if (anchor == null) {
      if (anchorConstraint != null)
        anchor = anchorConstraint.toString();
      else
        anchor = "ALL";
    }

    for (String featureString : activeFeatures) {
      String stringValue = wordConstraint.getTokenAnnotation().getFeatureMap().get(featureString);
      if(stringValue != null) {
        constraints.add("FEATURE(\"" + featureString + "\", "+stringValue+")");
      }
    }
    
    
    if (constraints.size() > 0) {
      String cStr = "";
      for (String constraintStr : constraints) {
        if (cStr.length() > 0)
          cStr += ", ";
        cStr += constraintStr;
      }
      result += "{" + cStr;
      if (!isMarkingItem)
        result += "}";
    }

    if (isMarkingItem) {
      if (constraints.size() == 0)
        result += "{";
      result += "->MARKONCE(" + whiskRule.getMarkName(slotIndex);
      if (patternSize > 1)
        result += ", " + (numberInRule + 1) + ", " + (numberInRule + patternSize);
      result += ")}";
    }
    if (isStarWildCard) {
      anchor += "*?";
      if(anchor.equals("ALL*?")) {
        anchor = "#";
      }
    }
    return anchor + result;
  }