|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.cilib.problem.dataset.DataSet net.sourceforge.cilib.problem.dataset.LocalDataSet
public class LocalDataSet
This class represents a local dataset, i.e. a local file on disk that contains lines that
represent patterns of the dataset. It is responsible for parsing this file and building
up an ArrayList
of ClusterableDataSet.Pattern
objects. It makes use of a few variables to
correctly parse the lines in the dataset and construct ClusterableDataSet.Pattern
objects from them.
The first variable that is of importance is the delimiter
variable. It specifies
the delimiter (actually a regular expression) that is used to split up the elements of a
single line of the dataset. The default delimiter is a whitespace character. Once
that is done, the beginIndex
specifies the column number/index where the
pattern's data begins. Likewise, the endIndex
specifies the column number/index
where the pattern's data ends. This index is inclusive. Lastly, the classIndex
specifies the column number/index that represents the pattern's class. If the
classIndex
is -1
then it means that the dataset does not have a
column for the class of the patterns, and in this case the filename of the dataset is
used as the class.
Field Summary | |
---|---|
protected int |
beginIndex
|
protected int |
classIndex
|
protected String |
delimiter
|
protected int |
endIndex
|
protected String |
fileName
|
Fields inherited from class net.sourceforge.cilib.problem.dataset.DataSet |
---|
patternExpression |
Constructor Summary | |
---|---|
LocalDataSet()
|
|
LocalDataSet(LocalDataSet rhs)
|
Method Summary | |
---|---|
LocalDataSet |
getClone()
Create a cloned copy of the current object and return it. |
byte[] |
getData()
Get the contents of the file on disk as an array of bytes. |
String |
getFile()
Get the name of the file that represents this dataset on disk. |
InputStream |
getInputStream()
Get the contents of the file on disk as an InputStream . |
ArrayList<ClusterableDataSet.Pattern> |
parseDataSet()
Parse the dataset, building up a list containing all the patterns in the dataset. |
void |
setBeginIndex(int bi)
Sets the index where the elements of the pattern begins. |
void |
setClassIndex(int ci)
Sets the index of the column that represents the class of the pattern. |
void |
setDelimiter(String d)
Sets the regular expression (as a String } that should be used as delimiter to
split a string into the elements of the pattern. |
void |
setEndIndex(int ei)
Sets the index where the elements of the pattern ends. |
void |
setFile(String fileName)
Set the name of the file that represents this dataset on disk. |
Methods inherited from class net.sourceforge.cilib.problem.dataset.DataSet |
---|
getPatternExpression, setPatternExpression |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected String fileName
protected String delimiter
protected int beginIndex
protected int endIndex
protected int classIndex
Constructor Detail |
---|
public LocalDataSet()
public LocalDataSet(LocalDataSet rhs)
Method Detail |
---|
public LocalDataSet getClone()
Cloneable
getClone
in interface Cloneable
getClone
in class DataSet
Object.clone()
public void setFile(String fileName)
fileName
- the name of the filepublic String getFile()
public byte[] getData()
getData
in class DataSet
public InputStream getInputStream()
InputStream
.
getInputStream
in class DataSet
InputStream
public ArrayList<ClusterableDataSet.Pattern> parseDataSet()
ArrayList
of ClusterableDataSet.Pattern
s containing all the patterns in this
dataset
IllegalArgumentException
- when
beginIndex
== endIndex
.public void setDelimiter(String d)
String
} that should be used as delimiter to
split a string into the elements of the pattern.
d
- the regular expression (as a String
) that should be used as
delimiter
IllegalArgumentException
- when the delimiter is empty ("") or null
public void setBeginIndex(int bi)
bi
- the starting index
IllegalArgumentException
- when the index is negativepublic void setEndIndex(int ei)
ei
- the ending index
IllegalArgumentException
- when the index is negativepublic void setClassIndex(int ci)
-1
then the filename of the dataset will be used as the class.
ci
- the index where the class resides
IllegalArgumentException
- when the index is <-1
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |