dice.data.io
Class ArffReader

java.lang.Object
  extended by dice.data.io.ArffReader
All Implemented Interfaces:
DataReader

public class ArffReader
extends java.lang.Object
implements DataReader

An DataReader implementation can read arff file. The usage of that class is demonstrated in BinaryClassificationByCV

Version:
0.000
Author:
Xiatian Zhang

Field Summary
 java.lang.String ATTRIBUTE
          The constant for "@attribute" label of arff file.
private  int attrSize
          The number of attributes.
 java.lang.String COMM
          Comma character.
 java.lang.String DATA
          The constant for "@data" label of arff file.
private  java.lang.String filePath
          The data source file.
private  boolean isSparse
          The flag indicate whether the data source is sparse of dense.
 int N_NUMERIC
          In memory, the numeric attribute is represent as "-1".
 int N_REAL
          In memory, the numeric attribute is represent as "0".
 java.lang.String NUMERIC
          The constant for "numeric" label of arff file, which indicates the attribute is numeric type.
 java.lang.String REAL
          The constant for "real" label of arff file, which indicates the attribute is real type.
 java.lang.String RELATION
          The constant for "@relation" label of arff file.
 java.lang.String SPLIT
          Split character.
 java.lang.String UNKNOWN
          In arff file, "?" means the missing data.
 
Constructor Summary
ArffReader()
           
 
Method Summary
private  void checkData()
          Check the data storage form in the source file.
private  SimpleInstances getDenseInstances()
          Get instances from dense source file.
 java.lang.String getFilePath()
          Get current source file path.
 SimpleInstances getInstances()
          Get the data set object Instances.
private  SimpleInstances getSparseInstances()
          Get the instances from sparse source file.
 void setAttrSize(int attrSize)
          Set the size of attributes.
 void setFilePath(java.lang.String filePath)
          Set current source file path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RELATION

public final java.lang.String RELATION
The constant for "@relation" label of arff file.

See Also:
Constant Field Values

ATTRIBUTE

public final java.lang.String ATTRIBUTE
The constant for "@attribute" label of arff file.

See Also:
Constant Field Values

DATA

public final java.lang.String DATA
The constant for "@data" label of arff file.

See Also:
Constant Field Values

NUMERIC

public final java.lang.String NUMERIC
The constant for "numeric" label of arff file, which indicates the attribute is numeric type.

See Also:
Constant Field Values

REAL

public final java.lang.String REAL
The constant for "real" label of arff file, which indicates the attribute is real type.

See Also:
Constant Field Values

N_NUMERIC

public final int N_NUMERIC
In memory, the numeric attribute is represent as "-1".

See Also:
Constant Field Values

N_REAL

public final int N_REAL
In memory, the numeric attribute is represent as "0".

See Also:
Constant Field Values

UNKNOWN

public final java.lang.String UNKNOWN
In arff file, "?" means the missing data.

See Also:
Constant Field Values

SPLIT

public final java.lang.String SPLIT
Split character.

See Also:
Constant Field Values

COMM

public final java.lang.String COMM
Comma character.

See Also:
Constant Field Values

filePath

private java.lang.String filePath
The data source file.


attrSize

private int attrSize
The number of attributes.


isSparse

private boolean isSparse
The flag indicate whether the data source is sparse of dense. True means sparse.

Constructor Detail

ArffReader

public ArffReader()
Method Detail

checkData

private void checkData()
Check the data storage form in the source file. If it is sparse, the function will set isSparse to true, otherwise to false.


getInstances

public SimpleInstances getInstances()
Description copied from interface: DataReader
Get the data set object Instances.

Specified by:
getInstances in interface DataReader
Returns:
The Instances object.

getSparseInstances

private SimpleInstances getSparseInstances()
Get the instances from sparse source file.

Returns:

getDenseInstances

private SimpleInstances getDenseInstances()
Get instances from dense source file.

Returns:

getFilePath

public java.lang.String getFilePath()
Get current source file path.

Returns:
the filePath

setFilePath

public void setFilePath(java.lang.String filePath)
Set current source file path.

Parameters:
filePath - the filePath to set

setAttrSize

public void setAttrSize(int attrSize)
Set the size of attributes.

Parameters:
attrSize -