public String getResultString()

in ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/kep/KEPLearner.java [894:947]


  public String getResultString() {
    StringBuffer ruleStrings = new StringBuffer();
    if (slotNamesWithBoundaries == null || slotNamesWithBoundaries.length == 0)
      return "No results available yet!";

    for (int i = 0; i < slotNamesWithBoundaries.length; i++) {
      List<KEPRule> ruleList = this.ruleLists.get(slotNamesWithBoundaries[i]);
      Type blockType = blocks.get(slotNamesWithBoundaries[i]);
      if (blockType != null
              && !(i > 0 && blocks.get(slotNamesWithBoundaries[i - 1]) != null && blocks
                      .get(slotNamesWithBoundaries[i - 1]).getName().equals(blockType.getName()))) {
        ruleStrings.append(
                "BLOCK(" + blockType.getShortName() + ") " + blockType.getShortName() + "{} { \n");
      }
      if (ruleList == null || ruleList.isEmpty()) {
        if (blockType != null && !(i < slotNamesWithBoundaries.length - 1
                && blocks.get(slotNamesWithBoundaries[i + 1]) != null && blocks
                        .get(slotNamesWithBoundaries[i + 1]).getName().equals(blockType.getName())))
          ruleStrings.append("} \n");
        continue;
      }
      ruleStrings.append("// " + slotNamesWithBoundaries[i] + " RULES \n");
      for (KEPRule rule : new ArrayList<KEPRule>(ruleList)) {
        ruleStrings.append((blockType != null ? "\t" : "") + rule.getRuleString() + "\t// "
                + rule.getCoveringStatistics() + "\n");
      }
      if (blockType != null && !(i < slotNamesWithBoundaries.length - 1
              && blocks.get(slotNamesWithBoundaries[i + 1]) != null
              && blocks.get(slotNamesWithBoundaries[i + 1]).getName().equals(blockType.getName())))
        ruleStrings.append("}");
      ruleStrings.append("\n");
    }
    StringBuffer boundaryCorrectors = new StringBuffer();
    StringBuffer wholeSlotCorrectors = new StringBuffer();
    boundaryCorrectors.append("\n // BOUNDARY CORRECTION RULES: \n");
    wholeSlotCorrectors.append("\n // CORRECTION RULES: \n");
    for (int i = 0; i < slotNamesWithBoundaries.length; i++) {
      List<KEPRule> ruleList = this.correctionRules.get(slotNamesWithBoundaries[i]);
      if (ruleList == null || ruleList.isEmpty())
        continue;
      for (KEPRule rule : ruleList) {
        if (slotNamesWithBoundaries[i].contains(TextRulerToolkit.LEFT_BOUNDARY_EXTENSION)
                || slotNamesWithBoundaries[i].contains(TextRulerToolkit.RIGHT_BOUNDARY_EXTENSION)) {
          boundaryCorrectors
                  .append(rule.getRuleString() + "\t// " + rule.getCoveringStatistics() + "\n");
        } else {
          wholeSlotCorrectors
                  .append(rule.getRuleString() + "\t// " + rule.getCoveringStatistics() + "\n");
        }
      }
    }
    return getFileHeaderString(true) + ruleStrings + boundaryCorrectors + "\n // CONNECTORS: \n"
            + getConnectorsRuleString() + wholeSlotCorrectors;
  }