/** * Determines and returns (if possible) the structure (internally the header) * of the data set as an empty set of instances. * * @return the structure of the data set as an empty set of Instances * @throws IOException if an error occurs */ @Override public Instances getStructure() throws IOException { if (m_structure == null) { if (m_sourceReader == null) { throw new IOException("No source has been specified"); } try { m_ArffReader = new ArffReader(m_sourceReader, 1, (getRetrieval() == BATCH)); m_ArffReader.setRetainStringValues(getRetainStringVals()); m_structure = m_ArffReader.getStructure(); } catch (Exception ex) { throw new IOException("Unable to determine structure as arff (Reason: " + ex.toString() + ")."); } } return new Instances(m_structure, 0); }
/** * Determines and returns (if possible) the structure (internally the header) * of the data set as an empty set of instances. * * @return the structure of the data set as an empty set of Instances * @throws IOException if an error occurs */ @Override public Instances getStructure() throws IOException { if (m_structure == null) { if (m_sourceReader == null) { throw new IOException("No source has been specified"); } try { m_ArffReader = new ArffReader(m_sourceReader, 1, (getRetrieval() == BATCH)); m_ArffReader.setRetainStringValues(getRetainStringVals()); m_structure = m_ArffReader.getStructure(); } catch (Exception ex) { throw new IOException("Unable to determine structure as arff (Reason: " + ex.toString() + ")."); } } return new Instances(m_structure, 0); }
/** * Reads the header of an ARFF file from a reader and reserves space for the * given number of instances. Lets the class index be undefined (negative). * * @param reader the reader * @param capacity the capacity * @throws IllegalArgumentException if the header is not read successfully or * the capacity is negative. * @throws IOException if there is a problem with the reader. * @deprecated instead of using this method in conjunction with the * <code>readInstance(Reader)</code> method, one should use the * <code>ArffLoader</code> or <code>DataSource</code> class * instead. * @see weka.core.converters.ArffLoader * @see weka.core.converters.ConverterUtils.DataSource */ // @ requires capacity >= 0; // @ ensures classIndex() == -1; @Deprecated public Instances(/* @non_null@ */Reader reader, int capacity) throws IOException { ArffReader arff = new ArffReader(reader, 0); Instances header = arff.getStructure(); initialize(header, capacity); m_Lines = arff.getLineNo(); }
/** * Reads the header of an ARFF file from a reader and reserves space for the * given number of instances. Lets the class index be undefined (negative). * * @param reader the reader * @param capacity the capacity * @throws IllegalArgumentException if the header is not read successfully or * the capacity is negative. * @throws IOException if there is a problem with the reader. * @deprecated instead of using this method in conjunction with the * <code>readInstance(Reader)</code> method, one should use the * <code>ArffLoader</code> or <code>DataSource</code> class * instead. * @see weka.core.converters.ArffLoader * @see weka.core.converters.ConverterUtils.DataSource */ // @ requires capacity >= 0; // @ ensures classIndex() == -1; @Deprecated public Instances(/* @non_null@ */Reader reader, int capacity) throws IOException { ArffReader arff = new ArffReader(reader, 0); Instances header = arff.getStructure(); initialize(header, capacity); m_Lines = arff.getLineNo(); }