类 ArffLoader.ArffReader
java.lang.Object
weka.core.converters.ArffLoader.ArffReader
- 所有已实现的接口:
RevisionHandler
- 封闭类:
- ArffLoader
Reads data from an ARFF file, either in incremental or batch mode.
Typical code for batch usage:
BufferedReader reader = new BufferedReader(new FileReader("/some/where/file.arff")); ArffReader arff = new ArffReader(reader); Instances data = arff.getData(); data.setClassIndex(data.numAttributes() - 1);Typical code for incremental usage:
BufferedReader reader = new BufferedReader(new FileReader("/some/where/file.arff")); ArffReader arff = new ArffReader(reader, 1000); Instances data = arff.getStructure(); data.setClassIndex(data.numAttributes() - 1); Instance inst; while ((inst = arff.readInstance(data)) != null) { data.add(inst); }
- 版本:
- $Revision: 11137 $
- 作者:
- Eibe Frank (eibe@cs.waikato.ac.nz), Len Trigg (trigg@cs.waikato.ac.nz), fracpete (fracpete at waikato dot ac dot nz)
-
构造器概要
构造器构造器说明ArffReader
(Reader reader) Reads the data completely from the reader.ArffReader
(Reader reader, int capacity) Reads only the header and reserves the specified space for instances.ArffReader
(Reader reader, Instances template, int lines) Reads the data without header according to the specified template.ArffReader
(Reader reader, Instances template, int lines, int capacity) Initializes the reader without reading the header according to the specified template. -
方法概要
修饰符和类型方法说明getData()
Returns the data that was readint
returns the current line numberReturns the revision string.Returns the header formatreadInstance
(Instances structure) Reads a single instance using the tokenizer and returns it.readInstance
(Instances structure, boolean flag) Reads a single instance using the tokenizer and returns it.
-
构造器详细资料
-
ArffReader
Reads the data completely from the reader. The data can be accessed via thegetData()
method.- 参数:
reader
- the reader to use- 抛出:
IOException
- if something goes wrong- 另请参阅:
-
ArffReader
Reads only the header and reserves the specified space for instances. Further instances can be read viareadInstance()
.- 参数:
reader
- the reader to usecapacity
- the capacity of the new dataset- 抛出:
IOException
- if something goes wrongIllegalArgumentException
- if capacity is negative- 另请参阅:
-
ArffReader
Reads the data without header according to the specified template. The data can be accessed via thegetData()
method.- 参数:
reader
- the reader to usetemplate
- the template headerlines
- the lines read so far- 抛出:
IOException
- if something goes wrong- 另请参阅:
-
ArffReader
Initializes the reader without reading the header according to the specified template. The data must be read via thereadInstance()
method.- 参数:
reader
- the reader to usetemplate
- the template headerlines
- the lines read so farcapacity
- the capacity of the new dataset- 抛出:
IOException
- if something goes wrong- 另请参阅:
-
-
方法详细资料
-
getLineNo
public int getLineNo()returns the current line number- 返回:
- the current line number
-
readInstance
Reads a single instance using the tokenizer and returns it.- 参数:
structure
- the dataset header information, will get updated in case of string or relational attributes- 返回:
- null if end of file has been reached
- 抛出:
IOException
- if the information is not read successfully
-
readInstance
Reads a single instance using the tokenizer and returns it.- 参数:
structure
- the dataset header information, will get updated in case of string or relational attributesflag
- if method should test for carriage return after each instance- 返回:
- null if end of file has been reached
- 抛出:
IOException
- if the information is not read successfully
-
getStructure
Returns the header format- 返回:
- the header format
-
getData
Returns the data that was read- 返回:
- the data
-
getRevision
Returns the revision string.- 指定者:
getRevision
在接口中RevisionHandler
- 返回:
- the revision
-