|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.ida.dataformat.ArffFile
public class ArffFile
A class for reading and writing Arff-Files.
You can either load a file, parse a string or a BufferedReader. Afterwards, you can extract the information with the methods getComment(), getNumberOfAttributes(), getAttributeName(), getAttributeType(), getAttributeData().
Alternative, you can construct an empty ArffFile object, and then use setComment(), defineAttribute(), add() to fill in the data and then save to a file with save(), or to a string with write().
The first comment in an ArffFile is extracted and made available through the *Comment() accessors. Usually, this comment contains some interesting information about the data set.
Currently, the class only supports numerical, string and nominal attributes. It also does not support sparse storage (yet).
| Constructor Summary | |
|---|---|
ArffFile()
Construct an empty ArffFile. |
|
| Method Summary | |
|---|---|
void |
add(java.lang.Object[] datum)
Add a datum. |
void |
defineAttribute(java.lang.String name,
java.lang.String type,
java.lang.String[] data)
Define a new attribute. |
java.lang.String |
dump()
Generate a string which describes the data set. |
java.lang.String[] |
getAttributeData(java.lang.String name)
Get additional information on the attribute. |
java.lang.String |
getAttributeName(int idx)
Get the name of an attribute. |
java.lang.String |
getAttributeType(java.lang.String name)
Get the type of an attribute. |
java.lang.String |
getComment()
Get the initial comment of the relation. |
int |
getDataSize()
|
java.lang.Object[] |
getDatum(int i)
|
int |
getNumberOfAttributes()
Get the number of attributes. |
java.lang.String |
getRelation()
Get the name of the relation. |
static ArffFile |
load(java.lang.String filename)
Load an ArffFile. |
static void |
main(java.lang.String[] args)
Main function for debugging. |
void |
parse(java.io.BufferedReader r)
Parse an ArffFile from a BufferedReader. |
static ArffFile |
parse(java.lang.String l)
Parse an ArffFile from a string. |
void |
save(java.lang.String filename)
Save the data into a file. |
void |
setComment(java.lang.String comment)
Set the initial comment of the relation. |
void |
setRelation(java.lang.String relation)
Set the name of the relation. |
java.lang.String |
write()
Write the ArffFile to a string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ArffFile()
| Method Detail |
|---|
public static ArffFile load(java.lang.String filename)
throws java.io.FileNotFoundException,
java.io.IOException,
ArffFileParseError
java.io.FileNotFoundException
java.io.IOException
ArffFileParseError
public static ArffFile parse(java.lang.String l)
throws java.io.IOException,
ArffFileParseError
java.io.IOException
ArffFileParseError
public void parse(java.io.BufferedReader r)
throws java.io.IOException
java.io.IOException
public void defineAttribute(java.lang.String name,
java.lang.String type,
java.lang.String[] data)
public java.lang.String dump()
public java.lang.String write()
public void save(java.lang.String filename)
throws java.io.IOException
java.io.IOExceptionpublic static void main(java.lang.String[] args)
public java.lang.String getRelation()
public void setRelation(java.lang.String relation)
public java.lang.String getComment()
public void setComment(java.lang.String comment)
public int getNumberOfAttributes()
public java.lang.String getAttributeName(int idx)
public java.lang.String getAttributeType(java.lang.String name)
public java.lang.String[] getAttributeData(java.lang.String name)
public void add(java.lang.Object[] datum)
public int getDataSize()
public java.lang.Object[] getDatum(int i)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||