edu.upenn.cis.pdtb.util
Class TreeEnumFeature

java.lang.Object
  extended byedu.upenn.cis.pdtb.util.TreeEnumFeature
All Implemented Interfaces:
java.lang.Comparable

public class TreeEnumFeature
extends java.lang.Object
implements java.lang.Comparable

This class is used to store a tree of features, specifically the semantic classes (or senses). The senses are organized in a hierarchy, where some connectives are classified generally as belonging for example to the class "Comparison" and other connectives are classified more specifically as belonging for example to the class "Comparison.Concession.Contra-expectation". To see a complete tree of the hierarchy of senses, go to the annotation manual available at The PDTB Page. To create a leaf node in this tree, use the constructor with one argument, for example:

 new TreeEnumFeature("Contra-expectation")
 
To create a parent to a leaf, use the constructor with two arguments, for example:
 new TreeEnumFeature("Comparison", new TreeEnumFeature[] { new TreeEnumFeature(
 		"Concession", new TreeEnumFeature[] {
 				new TreeEnumFeature("Contra-expectation"),
 				new TreeEnumFeature("Expectation") }) })
 
Calling getValuesLong() on this specific TreeEnumFeature will produce the following String array:
 { "Comparison", "Comparison.Concession",
 		"Comparison.Concession.Contra-expectation",
 		"Comparison.Concession.Expectation" }
 
Calling getValuesShort() on this specific TreeEnumFeature will produce something like the following String array, depending on the spacing:
 { "Comparison", "  Concession", "    Contra-expectation", "    Expectation" }
 
To get a node in the tree, given a String, use indexOf(). For example:
 new TreeEnumFeature("Comparison", new TreeEnumFeature[] { new TreeEnumFeature(
 		"Concession", new TreeEnumFeature[] {
 				new TreeEnumFeature("Contra-expectation"),
 				new TreeEnumFeature("Expectation") }) })
 		.indexOf("Comparison.Concession")
 
will return the Concession node, whose parent is the Comparison node. To then get the String "Concession", given this Concession node, use getName(). To get the String "Comparison.Concession", given this Concession node, use getValue(). For the Comparison node, getName() and getValue() will be the same. To use XPath to search all relations for the only the Comparison node and not it's children, use a query like:
 >::*[(attribute::*[regexp(local-name(),'sClassA|sClassB|sClass1A|sClass1B|sClass2A|sClass2B')andregexp(string(),'.*(Comparison)')])]
 
To also search for it's subclasses, use a query like
 >::*[(attribute::*[regexp(local-name(),'sClassA|sClassB|sClass1A|sClass1B|sClass2A|sClass2B')andregexp(string(),'.*(Comparison).*')])]
 

Author:
geraud

Constructor Summary
TreeEnumFeature(java.lang.String name)
          Instantiation for a leaf node
TreeEnumFeature(java.lang.String name, TreeEnumFeature[] children)
          Instantiation for an inner node
 
Method Summary
 int compareTo(java.lang.Object o)
           
 java.lang.String getName()
          Gets the name of the group of features
 TreeEnumFeature getParent()
          Gets the parent node
 java.lang.String getValue()
          Gets the feature string
 java.lang.String[] getValuesLong()
          Gets the the whole tree of features as a linear array, with the features in their full form
 java.lang.String[] getValuesShort()
          Gets the the whole tree of features as a linear array, with the features in their short form with spacing to replace parents
 TreeEnumFeature indexOf(java.lang.String value)
          Gets the TreeEnumFeature who has the given string value
static TreeEnumFeature[] TreeEnumFeatureFromList(java.util.LinkedList list)
          Returns an array of TreeEnumFeatures, given a formatted LinkedList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeEnumFeature

public TreeEnumFeature(java.lang.String name,
                       TreeEnumFeature[] children)
Instantiation for an inner node

Parameters:
name - A string representation of the feature group name
children - An TreeEnumFeature array of the feature's children

TreeEnumFeature

public TreeEnumFeature(java.lang.String name)
Instantiation for a leaf node

Parameters:
name - A string representation of the feature group name
Method Detail

TreeEnumFeatureFromList

public static TreeEnumFeature[] TreeEnumFeatureFromList(java.util.LinkedList list)
Returns an array of TreeEnumFeatures, given a formatted LinkedList

Parameters:
list - A LinkedList of .-formatted nodes
Returns:
an array of TreeEnumFeatures

getParent

public TreeEnumFeature getParent()
Gets the parent node

Returns:
The TreeEnumFeature parent

getName

public java.lang.String getName()
Gets the name of the group of features

Returns:
The name of the group of features

getValue

public java.lang.String getValue()
Gets the feature string

Returns:
The requested feature string

getValuesLong

public java.lang.String[] getValuesLong()
Gets the the whole tree of features as a linear array, with the features in their full form

Returns:
The whole String array of features

getValuesShort

public java.lang.String[] getValuesShort()
Gets the the whole tree of features as a linear array, with the features in their short form with spacing to replace parents

Returns:
The whole String array of features

indexOf

public TreeEnumFeature indexOf(java.lang.String value)
Gets the TreeEnumFeature who has the given string value

Parameters:
value - The feature string whose owner is requested
Returns:
The TreeEnumFeature node who has the given string value

compareTo

public final int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable