proper.xml
Class XMLExemplars

java.lang.Object
  extended by proper.xml.XMLExemplars

public class XMLExemplars
extends java.lang.Object

This class reads XML files representing Exemplars and writes Exemplars to XML.

Version:
$Revision: 1.2 $
Author:
FracPete

Field Summary
static java.lang.String DOCTYPE
          the DTD for the output
 
Constructor Summary
XMLExemplars()
          initializes the object
XMLExemplars(milk.core.Exemplars exemplars)
          initializes the object with the given exemplars
XMLExemplars(weka.core.Instances instances)
          initializes the object with the given instances (creates exemplars out of them), assumes that the bag id is the first attribute
 
Method Summary
 java.lang.String getDateFormat()
          returns the date format used in the DATE attributes
 java.lang.String getDoctype()
          returns the DTD used in the XML file
 milk.core.Exemplars getExemplars()
          returns the current exemplars object (either read or set)
 java.lang.String getPI()
          returns the processing instructions to use in the file
static void main(java.lang.String[] args)
          for testing only (first arg type [xml/arff], second arg filename)
 milk.core.Exemplars process(Document doc)
          transforms an XML document into an exemplars object
 Document process(milk.core.Exemplars exemplars)
          transforms Exemplars into an XML document
 boolean read(java.lang.String filename)
          reads the exemplars from the given XML file, returns TRUE if successful
 void setDateFormat(java.lang.String dateFormat)
          sets the date format to use in the attributes
 void setDoctype(java.lang.String doctype)
          sets the DTD to use in XML file
 void setExemplars(milk.core.Exemplars exemplars)
          sets the exemplars object to use
 void setInstances(weka.core.Instances instances)
          sets the instances object to use, assumes that the first attribute is the bag for creating an exemplars object
 void setPI(java.lang.String pi)
          sets the processing instructions to use in the file
static int stringToType(java.lang.String typeStr)
          returns the WEKA Attribute type of the given string, default is STRING
static java.lang.String typeToString(int type)
          returns a string representation of the given WEKA Attribute type, default is TYPE_STRING
 boolean write(java.lang.String filename)
          writes the current exemplars to the given filename, returns TRUE if successful
static boolean write(java.lang.String filename, milk.core.Exemplars exemplars)
          writes the given exemplars to the given file, in XML format, returns TRUE if successful
static boolean write(java.lang.String filename, weka.core.Instances instances)
          writes the given instances to the given file, in XML format, returns TRUE if successful.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOCTYPE

public static final java.lang.String DOCTYPE
the DTD for the output

See Also:
Constant Field Values
Constructor Detail

XMLExemplars

public XMLExemplars()
initializes the object


XMLExemplars

public XMLExemplars(milk.core.Exemplars exemplars)
initializes the object with the given exemplars


XMLExemplars

public XMLExemplars(weka.core.Instances instances)
initializes the object with the given instances (creates exemplars out of them), assumes that the bag id is the first attribute

Method Detail

setExemplars

public void setExemplars(milk.core.Exemplars exemplars)
sets the exemplars object to use


setInstances

public void setInstances(weka.core.Instances instances)
sets the instances object to use, assumes that the first attribute is the bag for creating an exemplars object


getExemplars

public milk.core.Exemplars getExemplars()
returns the current exemplars object (either read or set)


setDoctype

public void setDoctype(java.lang.String doctype)
sets the DTD to use in XML file

See Also:
XMLInstances.DOCTYPE

getDoctype

public java.lang.String getDoctype()
returns the DTD used in the XML file

See Also:
XMLInstances.DOCTYPE

setPI

public void setPI(java.lang.String pi)
sets the processing instructions to use in the file

See Also:
XMLInstances.PI

getPI

public java.lang.String getPI()
returns the processing instructions to use in the file

See Also:
XMLInstances.PI

setDateFormat

public void setDateFormat(java.lang.String dateFormat)
sets the date format to use in the attributes

See Also:
XMLInstances.DATE_FORMAT

getDateFormat

public java.lang.String getDateFormat()
returns the date format used in the DATE attributes

See Also:
XMLInstances.DATE_FORMAT

stringToType

public static int stringToType(java.lang.String typeStr)
returns the WEKA Attribute type of the given string, default is STRING

See Also:
Attribute.STRING

typeToString

public static java.lang.String typeToString(int type)
returns a string representation of the given WEKA Attribute type, default is TYPE_STRING

See Also:
XMLInstances.TYPE_STRING

process

public Document process(milk.core.Exemplars exemplars)
transforms Exemplars into an XML document


process

public milk.core.Exemplars process(Document doc)
transforms an XML document into an exemplars object


write

public boolean write(java.lang.String filename)
writes the current exemplars to the given filename, returns TRUE if successful


write

public static boolean write(java.lang.String filename,
                            milk.core.Exemplars exemplars)
writes the given exemplars to the given file, in XML format, returns TRUE if successful


write

public static boolean write(java.lang.String filename,
                            weka.core.Instances instances)
writes the given instances to the given file, in XML format, returns TRUE if successful. transforms them into exemplars, assuming that the first attribute is the bag


read

public boolean read(java.lang.String filename)
reads the exemplars from the given XML file, returns TRUE if successful


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
for testing only (first arg type [xml/arff], second arg filename)

Throws:
java.lang.Exception