|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.myra.datamining.io.Helper
net.sf.myra.datamining.io.ArffHelper
public class ArffHelper
Helper class to manipulate files in ARFF (Weka) format.
Nested Class Summary | |
---|---|
protected static class |
ArffHelper.UnsupportedAttribute
This class represents an unsupported attribute (e.g. |
Constructor Summary | |
---|---|
ArffHelper()
No instances allowed (private constructor). |
Method Summary | |
---|---|
protected java.lang.String |
getExtension()
Returns the default file extension. |
protected boolean |
isBlank(java.lang.String line)
Checks if the line is blank. |
protected boolean |
isComment(java.lang.String line)
Checks if the line begin with the comment character ('%'). |
static void |
main(java.lang.String[] args)
Utility method to convert the specified dataset file to ARFF format. |
Dataset |
read(java.io.File file)
Returns a Dataset instance that represents the data of
the specified ARFF file. |
Dataset |
read(java.io.Reader reader)
Returns a Dataset instance that represents the data of
the specified ARFF file. |
protected java.lang.String |
trim(java.lang.String s)
Returns a copy of the specified string, with single and double quotes, as well as leading and trailing spaces omitted. |
void |
write(java.io.File directory,
Dataset dataset)
Writes an ARFF file representing the specified dataset. |
void |
write(java.io.Writer writer,
Dataset dataset)
Writes an ARFF file representing the specified dataset. |
protected void |
writeAttribute(Attribute attribute,
java.io.PrintWriter writer)
Writes the ARFF attribute information. |
protected void |
writeData(Dataset dataset,
java.io.PrintWriter writer)
Writes the ARFF data section. |
protected void |
writeHeader(Metadata metadata,
java.io.PrintWriter writer)
Writes the ARFF header section. |
protected void |
writeTarget(Metadata metadata,
java.io.PrintWriter writer)
|
Methods inherited from class net.sf.myra.datamining.io.Helper |
---|
getHelper, getHelper, isCompressed, open, open, read, setCompressed |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ArffHelper()
Method Detail |
---|
public Dataset read(java.io.File file) throws java.io.IOException
Dataset
instance that represents the data of
the specified ARFF file.
read
in class Helper
file
- the file to read the data from.
Dataset
instance.
java.io.IOException
- if any file operation fails.public Dataset read(java.io.Reader reader) throws java.io.IOException
Dataset
instance that represents the data of
the specified ARFF file.
reader
- the input reader.
Dataset
instance.
java.io.IOException
- if any file operation fails.public void write(java.io.File directory, Dataset dataset) throws java.io.IOException
write
in class Helper
directory
- the output directory.dataset
- the dataset to be written.
java.io.IOException
public void write(java.io.Writer writer, Dataset dataset) throws java.io.IOException
write
in class Helper
writer
- the output writer.dataset
- the dataset to be written.
java.io.IOException
protected void writeHeader(Metadata metadata, java.io.PrintWriter writer)
metadata
- the metadata information.writer
- the writer instance.protected void writeTarget(Metadata metadata, java.io.PrintWriter writer)
protected void writeData(Dataset dataset, java.io.PrintWriter writer)
dataset
- the dataset instance.writer
- the writer instance.protected void writeAttribute(Attribute attribute, java.io.PrintWriter writer)
attribute
- the attribute to write.writer
- the writer instance.protected boolean isComment(java.lang.String line)
line
- the line to check.
true
if the line begins with the comment
character ('%'); false
otherwise.protected boolean isBlank(java.lang.String line)
line
- the line to check.
true
if the line is blank; false
otherwise.protected java.lang.String trim(java.lang.String s)
s
- the string to remove single and double quotes, as well as
leading and trailing spaces.
protected java.lang.String getExtension()
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- command-line arguments.
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |