|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectace.datatypes.Taxonomy
public class Taxonomy
Objects of this class each hold a taxonomy. Each class is stored as a string giving its name. The taxonomy is stored as a tree, with the root giving the name of the taxonomy. A given class may occur at more than one node in the tree.
Methods are available for adding classes, deleting classes, viewing the classes and various sub-sets of the classes, saving the classes to disk and loading the classes from disk. Methods are also available for checking which classes are in a taxonomy but not in a set of classificatiosns, and vice versa.
If the user only wishes to use a flat taxonomy, the addClass, deleteClass and getLeafLabels methods will be the most useful.
Field Summary | |
---|---|
javax.swing.tree.DefaultTreeModel |
taxonomy
The tree holding the taxonomy. |
Constructor Summary | |
---|---|
Taxonomy()
Generate an empty taxonomy with the name "Taxonomy". |
|
Taxonomy(javax.swing.tree.DefaultTreeModel existing_taxonomy)
Set the taxonomy to an existing DefaultTreeModel. |
|
Taxonomy(weka.core.Instances instances)
Generates a Taxonomy from a Weka ARFF file. |
|
Taxonomy(java.lang.String taxonomy_name)
Generate an empty taxonomy with the specified name. |
Method Summary | |
---|---|
void |
addChildClass(javax.swing.tree.DefaultMutableTreeNode new_node,
javax.swing.tree.DefaultMutableTreeNode parent_node)
Inserts the given new_node into the taxonomy as the last child of the given parent_node. |
void |
addClass(java.lang.String new_class_name)
Adds a new class with the given name to the taxonomy. |
void |
addSiblingClass(javax.swing.tree.DefaultMutableTreeNode new_node,
javax.swing.tree.DefaultMutableTreeNode sibling_node)
Inserts the given new_node into the taxonomy next to the given sibling_node. |
void |
deleteBranchOfTaxonomy(javax.swing.tree.DefaultMutableTreeNode node_to_delete)
Deletes the given node_to_delete and all of its children from the taxonomy. |
void |
deleteClass(java.lang.String name_of_class_to_delete)
Searches through the taxonomy and deletes all classes with the given name. |
static Taxonomy |
generateTaxonomy(SegmentedClassification[] classifications)
Automatically generates a flat taxonomy based on the class labels in the given SegmentedClassification object. |
java.lang.String[][] |
getAllParentsAndTheirDirectChildren()
Returns the name of each class with children and its direct descendants. |
java.lang.String[] |
getClassesInClassificationsButNotTaxonomy(SegmentedClassification[] seg_classes)
Returns an array listing the classes that are found in the given classifications (either overall classifications or classifications of sub-sections) but not in this taxonomy. |
java.lang.String[] |
getClassesInTaxonomyButNotInClassifications(SegmentedClassification[] seg_classes)
Returns an array listing the classes that are found in this taxonomy but not in the given classifications (either overall classifications or classifications of sub-sections). |
java.lang.String |
getFormattedTreeStructure()
Returns a string showing the entire taxonomy. |
java.lang.String[] |
getLeafLabels()
Returns an array holding the labels of all leaf classes in the taxonomy field. |
java.lang.String[][] |
getLeafsAndTheirParents()
Returns each leaf class in the taxonomy field and its ancestry. |
java.lang.String[] |
getMiddleLabels()
Returns an array holding the labels of the classes in the taxonomy field that are neither leaves nor parent classes. |
java.lang.String[] |
getParentLabels()
Returns an array holding the labels of all parent classes (i.e. |
boolean |
isTreeEmpty()
Returns true if the taxonomy field is empty and false if it is not. |
static Taxonomy |
parseTaxonomyFile(java.lang.String taxonomy_file_path)
Parses a taxonomy_file XML file and returns a Taxonomy object that has had its taxonomy field populated with the file's contents. |
static void |
saveTaxonomy(Taxonomy taxonomy_to_save,
java.io.File to_save_to,
java.lang.String comments)
Saves a taxonomy_file XML file with the contents specified in the taxonomy_to_save parameter and the comments specified in the comments parameter. |
static void |
setRootName(Taxonomy given_taxonomy,
java.lang.String file_path)
Sets the root of the given taxonomy to the name of the given file path (with directory structure and extension stripped off. |
void |
setTaxonomyName(java.lang.String taxonomy_name)
Sets the name of the stored taxonomy to the given taxonomy_name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public javax.swing.tree.DefaultTreeModel taxonomy
Constructor Detail |
---|
public Taxonomy()
public Taxonomy(java.lang.String taxonomy_name)
taxonomy_name
- The name to set as the name of the taxonomy.public Taxonomy(javax.swing.tree.DefaultTreeModel existing_taxonomy)
existing_taxonomy
- The tree to set the taxonomy field to.public Taxonomy(weka.core.Instances instances)
Method Detail |
---|
public void addClass(java.lang.String new_class_name)
new_class_name
- The name of the new class that is to
be added to the taxonomy.public void addChildClass(javax.swing.tree.DefaultMutableTreeNode new_node, javax.swing.tree.DefaultMutableTreeNode parent_node)
new_node
- The node that is to be inserted into
the taxonomy.parent_node
- The node that is already in the taxonomy
that is to be the parent of the new node.public void addSiblingClass(javax.swing.tree.DefaultMutableTreeNode new_node, javax.swing.tree.DefaultMutableTreeNode sibling_node) throws java.lang.Exception
new_node
- The node that is to be inserted into the taxonomy.sibling_node
- The node that is already in the taxonomy that is
to be at the same level and just preceeding the
new node.
java.lang.Exception
- Informative exceptions is thrown if the
sibling_node is not already in the taxonomy or if
the parent of the sibling_node is null.public void deleteClass(java.lang.String name_of_class_to_delete)
name_of_class_to_delete
- The name that classes must have
in order to be deleted.public void deleteBranchOfTaxonomy(javax.swing.tree.DefaultMutableTreeNode node_to_delete) throws java.lang.Exception
node_to_delete
- The node that is to be deleted.
java.lang.Exception
- An informative exception is thrown if the
parent of the node_to_delete is null.public void setTaxonomyName(java.lang.String taxonomy_name)
taxonomy_name
- The name to set as the name of the taxonomy.public java.lang.String getFormattedTreeStructure()
public java.lang.String[] getLeafLabels()
public java.lang.String[] getParentLabels()
public java.lang.String[] getMiddleLabels()
public java.lang.String[][] getLeafsAndTheirParents()
This information is returned in the form of a 2-D array of Strings. The first indice specifies a particular leaf class and its ancestors. he second indice specifies the particular ancestor of a given leaf class or the leaf class itself. Indice 0 always corresponds to the name of the leaf class itself, but the order of the ancestors is not necessarily meaningful.
public java.lang.String[][] getAllParentsAndTheirDirectChildren()
public boolean isTreeEmpty()
public java.lang.String[] getClassesInClassificationsButNotTaxonomy(SegmentedClassification[] seg_classes)
seg_classes
- The classifications to check.
public java.lang.String[] getClassesInTaxonomyButNotInClassifications(SegmentedClassification[] seg_classes)
seg_classes
- The classifications to check.
public static Taxonomy parseTaxonomyFile(java.lang.String taxonomy_file_path) throws java.lang.Exception
taxonomy_file_path
- The path of the XML file to parse.
java.lang.Exception
- Informative exceptions is thrown if an
invalid file or file path is specified.public static void saveTaxonomy(Taxonomy taxonomy_to_save, java.io.File to_save_to, java.lang.String comments) throws java.lang.Exception
taxonomy_to_save
- The taxonomy to save.to_save_to
- The file to save to.comments
- Any comments to be saved inside the
comments element of the XML file.
java.lang.Exception
- An informative exception is thrown if
the file cannot be saved.public static void setRootName(Taxonomy given_taxonomy, java.lang.String file_path)
given_taxonomy
- The Taxonomy to update.file_path
- The path of the file to base the root name on.public static Taxonomy generateTaxonomy(SegmentedClassification[] classifications)
classifications
- The SegmentedClassification object from which to
derive the classes of the Taxonomy.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |