@Test public void testGetHeader() { InstanceInformation header = loader.getStructure(); assertEquals(10, header.numAttributes()); assertEquals(9, header.classIndex()); assertEquals(true, header.attribute(0).isNumeric()); assertEquals(false, header.attribute(1).isNumeric()); assertEquals(false, header.attribute(2).isNumeric()); assertEquals(false, header.attribute(3).isNumeric()); assertEquals(true, header.attribute(4).isNumeric()); assertEquals(true, header.attribute(5).isNumeric()); assertEquals(true, header.attribute(6).isNumeric()); assertEquals(true, header.attribute(7).isNumeric()); assertEquals(true, header.attribute(8).isNumeric()); assertEquals(false, header.attribute(9).isNumeric()); assertEquals(7, header.attribute(2).numValues()); assertEquals(" <->", header.attribute(2).value(0)); assertEquals(" <?>", header.attribute(2).value(1)); assertEquals(" ->", header.attribute(2).value(2)); assertEquals(" ?>", header.attribute(2).value(3)); assertEquals(" who", header.attribute(2).value(4)); assertEquals(" <-", header.attribute(2).value(5)); assertEquals(" <?", header.attribute(2).value(6)); assertEquals(3, header.attribute(9).numValues()); assertEquals("Background", header.attribute(9).value(0)); assertEquals("Normal", header.attribute(9).value(1)); assertEquals("Botnet", header.attribute(9).value(2)); }
private InstanceInformation getHeader() { String relation = "file stream"; auxAttributes = new ArrayList<Attribute>(); int numAttributes = 0; try { streamTokenizer.nextToken(); while (streamTokenizer.ttype != StreamTokenizer.TT_EOF) { if (streamTokenizer.ttype == StreamTokenizer.TT_WORD && streamTokenizer.sval.startsWith("@") == true) { String token = streamTokenizer.sval.toUpperCase(); if (token.startsWith("@RELATION")) { streamTokenizer.nextToken(); relation = streamTokenizer.sval; } else if (token.startsWith("@ATTRIBUTE")) { streamTokenizer.nextToken(); String name = streamTokenizer.sval; if (name == null) { name = Double.toString(streamTokenizer.nval); } streamTokenizer.nextToken(); String type = streamTokenizer.sval; if (streamTokenizer.ttype == '{') { streamTokenizer.nextToken(); List<String> attributeLabels = new ArrayList<String>(); while (streamTokenizer.ttype != '}') { if (streamTokenizer.sval != null) { attributeLabels.add(streamTokenizer.sval); } else { attributeLabels.add(Double.toString(streamTokenizer.nval)); } streamTokenizer.nextToken(); } auxAttributes.add(new Attribute(name, attributeLabels)); ++numAttributes; } else { auxAttributes.add(new Attribute(name)); ++numAttributes; } } else if (token.startsWith("@DATA")) { streamTokenizer.nextToken(); break; } } streamTokenizer.nextToken(); } if (range != null) { this.range.setUpper(numAttributes); } } catch (IOException ex) { Logger.getLogger(ArffLoader.class.getName()).log(Level.SEVERE, null, ex); } return new InstanceInformation(relation, auxAttributes); }
ArffLoader implements Loader { private InstanceInformation getHeader() { String relation = "file stream"; auxAttributes = new ArrayList<Attribute>(); int numAttributes = 0; try { streamTokenizer.nextToken(); while (streamTokenizer.ttype != StreamTokenizer.TT_EOF) { if (streamTokenizer.ttype == StreamTokenizer.TT_WORD && streamTokenizer.sval.startsWith("@") == true) { String token = streamTokenizer.sval.toUpperCase(); if (token.startsWith("@RELATION")) { streamTokenizer.nextToken(); relation = streamTokenizer.sval; } else if (token.startsWith("@ATTRIBUTE")) { streamTokenizer.nextToken(); String name = streamTokenizer.sval; if (name == null) { name = Double.toString(streamTokenizer.nval); } streamTokenizer.nextToken(); String type = streamTokenizer.sval; if (streamTokenizer.ttype == '{') { streamTokenizer.nextToken(); List<String> attributeLabels = new ArrayList<String>(); while (streamTokenizer.ttype != '}') { if (streamTokenizer.sval != null) { attributeLabels.add(streamTokenizer.sval); } else { attributeLabels.add(Double.toString(streamTokenizer.nval)); } streamTokenizer.nextToken(); } auxAttributes.add(new Attribute(name, attributeLabels)); ++numAttributes; } else { auxAttributes.add(new Attribute(name)); ++numAttributes; } } else if (token.startsWith("@DATA")) { streamTokenizer.nextToken(); break; } } streamTokenizer.nextToken(); } if (range != null) { this.range.setUpper(numAttributes); } } catch (IOException ex) { Logger.getLogger(ArffLoader.class.getName()).log(Level.SEVERE, null, ex); } return new InstanceInformation(relation, auxAttributes); } }
ArffLoader implements Loader { private InstanceInformation getHeader() { String relation = "file stream"; auxAttributes = new ArrayList<Attribute>(); int numAttributes = 0; try { streamTokenizer.nextToken(); while (streamTokenizer.ttype != StreamTokenizer.TT_EOF) { if (streamTokenizer.ttype == StreamTokenizer.TT_WORD && streamTokenizer.sval.startsWith("@") == true) { String token = streamTokenizer.sval.toUpperCase(); if (token.startsWith("@RELATION")) { streamTokenizer.nextToken(); relation = streamTokenizer.sval; } else if (token.startsWith("@ATTRIBUTE")) { streamTokenizer.nextToken(); String name = streamTokenizer.sval; if (name == null) { name = Double.toString(streamTokenizer.nval); } streamTokenizer.nextToken(); String type = streamTokenizer.sval; if (streamTokenizer.ttype == '{') { streamTokenizer.nextToken(); List<String> attributeLabels = new ArrayList<String>(); while (streamTokenizer.ttype != '}') { if (streamTokenizer.sval != null) { attributeLabels.add(streamTokenizer.sval); } else { attributeLabels.add(Double.toString(streamTokenizer.nval)); } streamTokenizer.nextToken(); } auxAttributes.add(new Attribute(name, attributeLabels)); ++numAttributes; } else { auxAttributes.add(new Attribute(name)); ++numAttributes; } } else if (token.startsWith("@DATA")) { streamTokenizer.nextToken(); break; } } streamTokenizer.nextToken(); } if (range != null) { this.range.setUpper(numAttributes); } } catch (IOException ex) { Logger.getLogger(ArffLoader.class.getName()).log(Level.SEVERE, null, ex); } return new InstanceInformation(relation, auxAttributes); } ArffLoader(Reader reader, int size, int classAttribute);  ArffLoader(Reader reader);  ArffLoader(Reader reader, Range range); }
ArffLoader implements Loader { private InstanceInformation getHeader() { String relation = "file stream"; auxAttributes = new ArrayList<Attribute>(); int numAttributes = 0; try { streamTokenizer.nextToken(); while (streamTokenizer.ttype != StreamTokenizer.TT_EOF) { if (streamTokenizer.ttype == StreamTokenizer.TT_WORD && streamTokenizer.sval.startsWith("@") == true) { String token = streamTokenizer.sval.toUpperCase(); if (token.startsWith("@RELATION")) { streamTokenizer.nextToken(); relation = streamTokenizer.sval; } else if (token.startsWith("@ATTRIBUTE")) { streamTokenizer.nextToken(); String name = streamTokenizer.sval; if (name == null) { name = Double.toString(streamTokenizer.nval); } streamTokenizer.nextToken(); String type = streamTokenizer.sval; if (streamTokenizer.ttype == '{') { streamTokenizer.nextToken(); List<String> attributeLabels = new ArrayList<String>(); while (streamTokenizer.ttype != '}') { if (streamTokenizer.sval != null) { attributeLabels.add(streamTokenizer.sval); } else { attributeLabels.add(Double.toString(streamTokenizer.nval)); } streamTokenizer.nextToken(); } auxAttributes.add(new Attribute(name, attributeLabels)); ++numAttributes; } else { auxAttributes.add(new Attribute(name)); ++numAttributes; } } else if (token.startsWith("@DATA")) { streamTokenizer.nextToken(); break; } } streamTokenizer.nextToken(); } if (range != null) { this.range.setUpper(numAttributes); } } catch (IOException ex) { Logger.getLogger(ArffLoader.class.getName()).log(Level.SEVERE, null, ex); } return new InstanceInformation(relation, auxAttributes); } ArffLoader(Reader reader, int size, int classAttribute);  ArffLoader(Reader reader);  ArffLoader(Reader reader, Range range); InstanceInformation getStructure(); Instance readInstance(); Instance readInstance(Reader reader); Instance readInstanceDense(); }
ArffLoader implements Loader { private InstanceInformation getHeader() { String relation = "file stream"; auxAttributes = new ArrayList<Attribute>(); int numAttributes = 0; try { streamTokenizer.nextToken(); while (streamTokenizer.ttype != StreamTokenizer.TT_EOF) { if (streamTokenizer.ttype == StreamTokenizer.TT_WORD && streamTokenizer.sval.startsWith("@") == true) { String token = streamTokenizer.sval.toUpperCase(); if (token.startsWith("@RELATION")) { streamTokenizer.nextToken(); relation = streamTokenizer.sval; } else if (token.startsWith("@ATTRIBUTE")) { streamTokenizer.nextToken(); String name = streamTokenizer.sval; if (name == null) { name = Double.toString(streamTokenizer.nval); } streamTokenizer.nextToken(); String type = streamTokenizer.sval; if (streamTokenizer.ttype == '{') { streamTokenizer.nextToken(); List<String> attributeLabels = new ArrayList<String>(); while (streamTokenizer.ttype != '}') { if (streamTokenizer.sval != null) { attributeLabels.add(streamTokenizer.sval); } else { attributeLabels.add(Double.toString(streamTokenizer.nval)); } streamTokenizer.nextToken(); } auxAttributes.add(new Attribute(name, attributeLabels)); ++numAttributes; } else { auxAttributes.add(new Attribute(name)); ++numAttributes; } } else if (token.startsWith("@DATA")) { streamTokenizer.nextToken(); break; } } streamTokenizer.nextToken(); } if (range != null) { this.range.setUpper(numAttributes); } } catch (IOException ex) { Logger.getLogger(ArffLoader.class.getName()).log(Level.SEVERE, null, ex); } return new InstanceInformation(relation, auxAttributes); } ArffLoader(Reader reader, int size, int classAttribute);  ArffLoader(Reader reader);  ArffLoader(Reader reader, Range range); InstanceInformation getStructure(); Instance readInstance(); Instance readInstance(Reader reader); Instance readInstanceDense();  }