Ejemplo n.º 1
0
  /**
   * Generating the header of the output file @ param p PrintStream
   *
   * @return Nothing
   */
  private void CopyHeaderTest(PrintStream p) {

    // Header of the output file
    p.println("@relation " + Attributes.getRelationName());
    p.print(Attributes.getInputAttributesHeader());
    p.print(Attributes.getOutputAttributesHeader());
    p.println(Attributes.getInputHeader());
    p.println(Attributes.getOutputHeader());
    p.println("@data");
  }
Ejemplo n.º 2
0
  /**
   * It prints the dataset to the specified PrintWriter. The order of the attributes is the same as
   * in the original file
   *
   * @param out is the PrintWriter where to print
   * @param printInOut indicates if the @inputs (1), @outputs(2), both of them (3) or any (0) has to
   *     be printed
   */
  public void printAsOriginal(PrintWriter out, int printInOut) {
    /*Printing the header as the original one*/
    out.println(header);

    if (storeAttributesAsNonStatic && attributes != null) {
      if (printInOut == 1 || printInOut == 3) out.println(attributes.getInputHeader());
      if (printInOut == 2 || printInOut == 3) out.println(attributes.getOutputHeader());
    } else {
      if (printInOut == 1 || printInOut == 3) out.println(Attributes.getInputHeader());
      if (printInOut == 2 || printInOut == 3) out.println(Attributes.getOutputHeader());
    }

    out.print("@data");
    for (int i = 0; i < instanceSet.length; i++) {
      out.println();
      if (storeAttributesAsNonStatic && attributes != null)
        instanceSet[i].printAsOriginal(attributes, out);
      else instanceSet[i].printAsOriginal(out);
    }
  } // end printAsOriginal
Ejemplo n.º 3
0
  /**
   * It does return a new header (not necessary the same header as the input file one). It only
   * includes the valid attributes, those ones defined in @inputs and @outputs (or taken as that
   * role following the keel format specification).
   *
   * @return a String with the new header
   */
  public String getNewHeader() {
    String line = "";
    Attribute[] attrs = null;

    // Getting the relation name and the attributes
    if (storeAttributesAsNonStatic && attributes != null) {
      line = "@relation " + attributes.getRelationName() + "\n";
      attrs = attributes.getInputAttributes();
    } else {
      line = "@relation " + Attributes.getRelationName() + "\n";
      attrs = Attributes.getInputAttributes();
    }

    for (int i = 0; i < attrs.length; i++) {
      line += attrs[i].toString() + "\n";
    }

    // Gettin all the outputs attributes
    if (storeAttributesAsNonStatic && attributes != null) {
      attrs = attributes.getOutputAttributes();
      line += attrs[0].toString() + "\n";

      // Getting @inputs and @outputs
      line += attributes.getInputHeader() + "\n";
      line += attributes.getOutputHeader() + "\n";
    } else {
      attrs = Attributes.getOutputAttributes();
      line += attrs[0].toString() + "\n";

      // Getting @inputs and @outputs
      line += Attributes.getInputHeader() + "\n";
      line += Attributes.getOutputHeader() + "\n";
    }

    return line;
  } // end getNewHeader