Example #1
0
    /**
     * obtain the names of the output files from the parameter file
     *
     * @param s is the StringTokenizer
     */
    private void getOutputFiles(StringTokenizer s) {
      String val = s.nextToken();

      trainFileNameOutput = s.nextToken().replace('"', ' ').trim();
      testFileNameOutput = s.nextToken().replace('"', ' ').trim();
      extraFileNameOutput = s.nextToken().replace('"', ' ').trim();
    }
Example #2
0
    /**
     * obtain a string value from the parameter file
     *
     * @param s is the StringTokenizer
     */
    private String getParamString(StringTokenizer s) {
      String contenido = "";
      String val = s.nextToken();
      while (s.hasMoreTokens()) contenido += s.nextToken() + " ";

      return contenido.trim();
    }
Example #3
0
    /**
     * Constructor of the Class Parametros
     *
     * @param nombreFileParametros is the pathname of input parameter file
     */
    Parametros(String nombreFileParametros) {

      try {
        int i;
        String fichero, linea, tok;
        StringTokenizer lineasFile, tokens;

        /* read the parameter file using Files class */
        fichero = Files.readFile(nombreFileParametros);
        fichero += "\n";

        /* remove all \r characters. it is neccesary for a correst use in Windows and UNIX  */
        fichero = fichero.replace('\r', ' ');

        /* extracts the differents tokens of the file */
        lineasFile = new StringTokenizer(fichero, "\n");

        i = 0;
        while (lineasFile.hasMoreTokens()) {

          linea = lineasFile.nextToken();
          i++;
          tokens = new StringTokenizer(linea, " ,\t");
          if (tokens.hasMoreTokens()) {

            tok = tokens.nextToken();
            if (tok.equalsIgnoreCase("algorithm")) nameAlgorithm = getParamString(tokens);
            else if (tok.equalsIgnoreCase("inputdata")) getInputFiles(tokens);
            else if (tok.equalsIgnoreCase("outputdata")) getOutputFiles(tokens);
            else if (tok.equalsIgnoreCase("seed")) seed = getParamLong(tokens);
            else throw new java.io.IOException("Syntax error on line " + i + ": [" + tok + "]\n");
          }
        }

      } catch (java.io.FileNotFoundException e) {
        System.err.println(e + "Parameter file");
      } catch (java.io.IOException e) {
        System.err.println(e + "Aborting program");
        System.exit(-1);
      }

      /** show the read parameter in the standard output */
      String contents = "-- Parameters echo --- \n";
      contents += "Algorithm name: " + nameAlgorithm + "\n";
      contents += "Input Train File: " + trainFileNameInput + "\n";
      contents += "Input Test File: " + testFileNameInput + "\n";
      contents += "Output Train File: " + trainFileNameOutput + "\n";
      contents += "Output Test File: " + testFileNameOutput + "\n";
      System.out.println(contents);
    }
Example #4
0
 /**
  * obtain a long value from the parameter file
  *
  * @param s is the StringTokenizer
  */
 private long getParamLong(StringTokenizer s) {
   String val = s.nextToken();
   val = s.nextToken();
   return Long.parseLong(val);
 }
Example #5
0
 /**
  * obtain an integer value from the parameter file
  *
  * @param s is the StringTokenizer
  */
 private int getParamInt(StringTokenizer s) {
   String val = s.nextToken();
   val = s.nextToken();
   return Integer.parseInt(val);
 }
Example #6
0
 /**
  * obtain a float value from the parameter file
  *
  * @param s is the StringTokenizer
  */
 private double getParamFloat(StringTokenizer s) {
   String val = s.nextToken();
   val = s.nextToken();
   return Float.parseFloat(val);
 }