/** * It reads the information in the header of the file. It reads relation's name, attributes' * names, and inputs and outputs. * * @param parser is the parser of the data set * @param isTrain is a boolean indicating if this is a train set (and so parameters information * must be read) or a test set (parameters information has not to be read). */ public void parseHeader(InstanceParser parser, boolean isTrain) { // 1. Declaration of variables Vector inputAttrNames = new Vector(); Vector outputAttrNames = new Vector(); boolean inputsDef = false; boolean outputsDef = false; String line, aux; header = ""; int attCount = 0, lineCount = 0; attHeader = null; while (!(line = parser.getLine().trim()).equalsIgnoreCase("@data")) { line = line.trim(); // System.out.println (" > Line read: " + line +"." ); lineCount++; if (line.toLowerCase().indexOf("@relation") != -1) { if (isTrain) Attributes.setRelationName(line.replaceAll("@relation", "")); } if (line.toLowerCase().indexOf("@attribute") != -1) { if (isTrain) insertAttribute(line); attCount++; } if (line.toLowerCase().indexOf("@inputs") != -1) { attHeader = header; inputsDef = true; aux = line.substring(8); if (isTrain) insertInputOutput(aux, lineCount, inputAttrNames, "inputs", isTrain); } if (line.toLowerCase().indexOf("@outputs") != -1) { if (attHeader == null) attHeader = header; outputsDef = true; // System.out.println ( " >>> Defining the output !!!"); aux = line.substring(8); if (isTrain) insertInputOutput(aux, lineCount, outputAttrNames, "outputs", isTrain); System.out.println(" >> Size of the output is: " + outputAttrNames.size()); } header += line + "\n"; } if (attHeader == null) attHeader = header; processInputsAndOutputs(isTrain, inputsDef, outputsDef, outputAttrNames, inputAttrNames); } // end headerParse