|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.converters.AbstractClassHierarchyParser
weka.core.converters.ClassTreeParser
ClassTreeParser is a ClassHierarchyParser which provides as ClassHierarchy-structure
a ClassTree
Field Summary | |
private java.util.List |
classNames
Provides the class-names of a nominal class-attribute after initialization with the init(Instances) -method. |
private java.lang.String |
encodedHierarchy
The encoded hierarchy currently to be parsed by this ClassTreeParser. |
static java.lang.String |
ILLEGAL_ARGUMENT
Error-message for an exception thrown in case of a invalid argument. |
static char |
LEFT
Lefthand-side delimiter of a set of classes or of superclasses. |
static char |
RIGHT
Righthand-side delimiter of a set of classes or of superclasses. |
static java.lang.String |
SEPARATOR
Separator of two sets of classes or of superclasses. |
Constructor Summary | |
ClassTreeParser()
|
Method Summary | |
private ClassTree |
decodeClassTree(java.lang.String encodedClassTree)
Decodes the given code recursively. |
ClassHierarchy |
getClassHierarchy()
Returns the classHierarchy encoded in the currently set encodedHierarchy. |
java.lang.String |
getEncodedHierarchy()
Returns the currently encoded hierarchy. |
void |
init(Instances instanceInfo)
Inits the ClassTreeParser. |
static void |
main(java.lang.String[] args)
Method to test a hierarchy with respect to given Instances. |
void |
setEncodedHierarchy(java.lang.String encodedHierarchy)
The given String is supposed to have no whitespace-signs and to collect classes as a comma-separated list delimited by left- and right-brackets - so superclasses are collected as comma-separated list of substrings delimited by left- and right-brackets. |
boolean |
validate()
Validates the currently encoded hierarchy with respect to the Instances given in initialization. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final char LEFT
public static final char RIGHT
public static final java.lang.String SEPARATOR
public static final java.lang.String ILLEGAL_ARGUMENT
private java.util.List classNames
init(Instances)
-method.
private java.lang.String encodedHierarchy
Constructor Detail |
public ClassTreeParser()
Method Detail |
public void init(Instances instanceInfo) throws UnsupportedAttributeTypeException
AbstractClassHierarchyParser#init(Instances)
.
Furthermore the classNames
are set according to the class names occuring in the given Instances.
This enables validation of a hierarchy, that must contain all class names and only the here defined class names.
init
in interface ClassHierarchyParser
init
in class AbstractClassHierarchyParser
UnsupportedAttributeTypeException
ClassHierarchyParser.init(Instances)
public void setEncodedHierarchy(java.lang.String encodedHierarchy)
{{{a,b,c},{d,e},{f,g,h}},{{i,j},{k,l,m}}}Note that single classes among subtrees are supposed to be parenthesized e.g.:
{{a,b},{c},{d,e}}The classHierarchy provided by this method will be an instance of
ClassTree
.
encodedHierarchy
- the encoded hierarchy to be decodedClassHierarchyParser.setEncodedHierarchy(java.lang.String)
public java.lang.String getEncodedHierarchy()
ClassHierarchyParser.getEncodedHierarchy()
public ClassHierarchy getClassHierarchy() throws java.text.ParseException
ClassTree
.
java.text.ParseException
- in case of a invalid hierarchy-code with respect to the Instances set int the init(Instances)
-methodClassHierarchyParser.getClassHierarchy()
public boolean validate() throws java.text.ParseException
classNames
during initialization,
each class once, or if the hierarchy encoding String is syntactically wrong.
java.text.ParseException
- if the currently set encodedHierarchy is invalid in some mannerprivate ClassTree decodeClassTree(java.lang.String encodedClassTree) throws java.lang.IllegalArgumentException
encodedClassTree
- the code of a hierarchy to be decoded
java.lang.IllegalArgumentException
- in case of an invalid code
leading to empty Strings or empty subtreespublic static void main(java.lang.String[] args) throws java.lang.Exception
args
- expected arguments are:
java.lang.Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |