public String renderCSVTable(int query, boolean ascending) {
    final String COL_SEP = "\t";
    final String LINE_SEP = ";\n";
    Map<Integer, Map<SimilarityValue, Double>> simiDevelopment =
        m_algorithm.getSimiDevelopment(query, false);
    StringBuilder sb = new StringBuilder();
    // table head
    sb.append("i");

    List<SimilarityValue> sorted =
        getSortedAnswers(simiDevelopment.get(simiDevelopment.size() - 1), ascending);
    for (SimilarityValue v : sorted) {
      sb.append(COL_SEP + getShortForm(v));
    }
    sb.append(LINE_SEP);

    // table body
    for (Integer i : simiDevelopment.keySet()) {
      sb.append(i);
      for (SimilarityValue v : sorted) {
        sb.append(
            COL_SEP
                + EasyMath.round(
                    simiDevelopment.get(i).get(v),
                    (Integer)
                        m_specification
                            .getParameters()
                            .getValue(GeneralParameters.DECIMAL_ACCURACY)));
      }
      sb.append(LINE_SEP);
    }
    return sb.toString();
  }
 public String renderInstanceList(
     final Map<OWLNamedIndividual, Double> instances, boolean ascending) {
   List<OWLNamedIndividual> sorted = getSortedAnswers(instances, ascending);
   StringBuilder sb = new StringBuilder();
   sb.append(sorted.size() + " answers");
   if (m_specification.isTopK() && m_specification.getThreshold() < sorted.size())
     sb.append(
         " (additional results with the same similarity as answer "
             + (int) m_specification.getThreshold()
             + " are included)");
   sb.append(":\n");
   for (OWLNamedIndividual ind : sorted) {
     sb.append(
         ind.toString()
             + "\t"
             + "similarity: "
             + EasyMath.round(
                 instances.get(ind),
                 (Integer)
                     m_specification.getParameters().getValue(GeneralParameters.DECIMAL_ACCURACY))
             + "\n");
   }
   return sb.toString();
 }
  public String renderASCIITable(int query, boolean ascending) {
    Map<Integer, Map<SimilarityValue, Double>> simiDevelopment =
        m_algorithm.getSimiDevelopment(query, false);
    if (simiDevelopment.keySet().size() == 0) return "";
    StringBuilder sb = new StringBuilder();
    int preLength = (simiDevelopment.keySet().size() + "").length();
    for (int i = 0; i < preLength - 1; i++) {
      sb.append(" ");
    }
    sb.append("i");
    List<SimilarityValue> sorted =
        getSortedAnswers(simiDevelopment.get(simiDevelopment.size() - 1), ascending);

    // determine maximal width of any element per column
    Map<SimilarityValue, Integer> widths = new HashMap<SimilarityValue, Integer>();
    // init with table head
    for (SimilarityValue v : sorted) {
      widths.put(v, getShortForm(v).length());
    }
    for (Integer i : simiDevelopment.keySet()) {
      for (SimilarityValue v : sorted) {
        double value = simiDevelopment.get(i).get(v);
        value =
            EasyMath.round(
                value,
                (Integer)
                    m_specification.getParameters().getValue(GeneralParameters.DECIMAL_ACCURACY));
        widths.put(v, Math.max((value + "").length(), widths.get(v)));
      }
    }
    int totalWidth = preLength;
    for (SimilarityValue v : sorted) {
      totalWidth += 1 + widths.get(v); // +1 for spacing
    }

    // continue table-head
    for (SimilarityValue v : sorted) {
      int curElemLength = getShortForm(v).length();
      for (int i = 0; i <= widths.get(v) - curElemLength; i++) {
        sb.append(" ");
      }
      sb.append(getShortForm(v));
    }

    sb.append("\n");
    for (int i = 0; i < totalWidth; i++) {
      sb.append("-");
    }

    sb.append("\n");
    for (int i = 0; i < simiDevelopment.keySet().size(); i++) {
      for (int j = 0; j < preLength - ("" + i).length(); j++) {
        sb.append(" ");
      }
      sb.append(i);

      for (SimilarityValue v : sorted) {
        Double d =
            EasyMath.round(
                simiDevelopment.get(i).get(v),
                (Integer)
                    m_specification.getParameters().getValue(GeneralParameters.DECIMAL_ACCURACY));
        for (int j = 0; j <= widths.get(v) - ("" + d).length(); j++) {
          sb.append(" ");
        }
        sb.append(d);
      }

      sb.append("\n");
    }

    return sb.toString();
  }