public class TypeHierarchy extends POSet
TypeHierarchyNode
Modifier and Type | Class and Description |
---|---|
static class |
TypeHierarchy.KindOfHierarchy |
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_BOTTOM_LABEL |
protected TypeHierarchyNode |
infinum |
protected TypeHierarchy.KindOfHierarchy |
kind |
(package private) TypeMatchingRuleSet |
matchRules |
protected String |
name |
static String |
RELATION_DEFAULT_NAME |
static String |
RELATION_DEFAULT_TOP_LABEL |
protected TypeHierarchyNode |
relationRoot |
protected TypeHierarchyNode |
root |
static String |
TYPE_DEFAULT_NAME |
static String |
TYPE_DEFAULT_TOP_LABEL |
protected TypeHierarchyNode |
typeRoot |
Constructor and Description |
---|
TypeHierarchy()
Creates a new hierarchy with the same root values as the other
constructors, but uses TYPE_DEFAULT_NAME and makes it a type hierarchy by
default.
|
TypeHierarchy(String newname,
TypeHierarchy.KindOfHierarchy kind)
Creates a new hierarchy, but it is not empty.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addSubtypeToType(GNode subtypeObject,
GNode supertypeObject)
Adds the label of the supertype to the hierarchy if it isn't there.
|
boolean |
addSubtypeToType(String subtypeLabel,
String supertypeLabel)
Basic construction unit for hierarchy.
|
void |
addToTopAndBottom(TypeHierarchyNode node)
Makes sure that the already added-node is linked to the top and bottom.
|
TypeHierarchyNode |
addTypeLabel(String name)
Adds a label in a node to the hierarchy.
|
TypeHierarchyNode |
getBottom()
Get the node at the bottom of the hierarchy.
|
ArrayList<String> |
getKeys()
Get all the type name keys in this hierarchy.
|
ArrayList<String> |
getLabelsAsValues()
Get all the type labels in this hierarchy.
|
String |
getName()
Get the name of this hierarchy, the one given when it was created or by
setName.
|
TypeHierarchyNode |
getNodeByValue(String value)
Finds a node whose key (previously transformed from its value) matches
the value once it is also transformed.
|
TypeHierarchyNode |
getTop()
Return the node at the top of this hierarchy.
|
boolean |
isIgnoreCase()
Convenience method to tell whether there's an ignore case rule
|
boolean |
isIgnoreSpaces()
Convenience method to tell whether there's an ignore spaces rule
|
boolean |
isIgnoreSpecial()
Convenience method to tell whether there's an ignore special characters
rule
|
String |
isRedundantSuperSubtype(String supertypeString,
String subtypeString)
Detects whether adding a specialization between the two terms will create
a redundant or cyclic hierarchy.
|
String |
makeKey(String value)
Apply the rules, successively transforming the value into the key.
|
boolean |
matchByRules(TypeMatchingRuleSet rules,
TypeHierarchyNode node,
String value)
Determine whether a node's value matches a given value after applying the
rules.
|
boolean |
matchByRules(TypeMatchingRuleSet rules,
TypeHierarchyNode node1,
TypeHierarchyNode node2)
Determine whether two nodes match values after applying the rules.
|
boolean |
removeSuperTypeFromType(GraphObject supertypeObject,
GraphObject subtypeObject)
Removes the super/sub type relationship between the nodes.
|
boolean |
removeSuperTypeFromType(String supertypeString,
String subtypeString)
Removes the super/sub type relationship between the nodes.
|
boolean |
removeSuperTypeFromType(TypeHierarchyNode sup,
TypeHierarchyNode sub) |
boolean |
removeTypeLabel(String value)
Removes a label from the hierarchy, without any super or sub
types.
|
void |
setIgnoreCase(boolean ignoreCase)
Convenience method to set an ignore/consider case rule.
|
void |
setIgnoreSpaces(boolean ignoreSpaces)
Convenience method to set an ignore/consider spaces rule.
|
void |
setIgnoreSpecial(boolean ignoreSpecial)
Convenience method to set an ignore/consider special characters rule.
|
void |
setName(String name)
Set the human-readable name of this hierarchy.
|
String |
showHierarchy() |
String |
showHierarchy(String start)
Displays all hierarchy nodes in very clunky text
|
addNode, clear, deleteNode, getCardinality, getNodeByKey
public static String TYPE_DEFAULT_TOP_LABEL
public static String RELATION_DEFAULT_TOP_LABEL
public static String DEFAULT_BOTTOM_LABEL
public static String TYPE_DEFAULT_NAME
public static String RELATION_DEFAULT_NAME
protected TypeHierarchyNode typeRoot
protected TypeHierarchyNode relationRoot
protected TypeHierarchyNode root
protected TypeHierarchyNode infinum
protected String name
protected TypeHierarchy.KindOfHierarchy kind
TypeMatchingRuleSet matchRules
public TypeHierarchy(String newname, TypeHierarchy.KindOfHierarchy kind)
newname
- An optional name for this hierarchypublic TypeHierarchy()
public TypeHierarchyNode getTop()
public TypeHierarchyNode getBottom()
public String getName()
public void setName(String name)
name
- public String makeKey(String value)
value
- the original value to be stored.public boolean isIgnoreCase()
public void setIgnoreCase(boolean ignoreCase)
ignoreCase
- true if we want to set IgnoreCase, false if we want to
set ConsiderCase. Removes a conflicting rule if present.public boolean isIgnoreSpaces()
public void setIgnoreSpaces(boolean ignoreSpaces)
ignoreSpaces
- true if we want to set IgnoreSpaces, false if we want
to set ConsiderSpaces. Removes a conflicting rule if present.public boolean isIgnoreSpecial()
public void setIgnoreSpecial(boolean ignoreSpecial)
ignoreSpecial
- true if we want to set IgnoreSpecial, false if we want
to set ConsiderSpecial. Removes a conflicting rule if present.public void addToTopAndBottom(TypeHierarchyNode node)
node
- A node that has already been addedpublic TypeHierarchyNode addTypeLabel(String name)
name
- of the label to be added.public boolean removeTypeLabel(String value)
value
- of the label to be removed.public ArrayList<String> getKeys()
public ArrayList<String> getLabelsAsValues()
public boolean addSubtypeToType(GNode subtypeObject, GNode supertypeObject)
subtypeObject
- supertypeObject
- public boolean addSubtypeToType(String subtypeLabel, String supertypeLabel)
subtypeLabel
- The label being used as a subtype. will be turned
into a key before insertingsupertypeLabel
- The label being used as a supertype. will be turned
into a key before inserting.public boolean removeSuperTypeFromType(GraphObject supertypeObject, GraphObject subtypeObject)
supertypeObject
- subtypeObject
- public boolean removeSuperTypeFromType(String supertypeString, String subtypeString)
supertypeString
- The label being used as a supertype.subtypeString
- public boolean removeSuperTypeFromType(TypeHierarchyNode sup, TypeHierarchyNode sub)
public boolean matchByRules(TypeMatchingRuleSet rules, TypeHierarchyNode node1, TypeHierarchyNode node2)
rules
- The rules to be appliednode1
- A first node -- the order does not matternode2
- a second nodepublic boolean matchByRules(TypeMatchingRuleSet rules, TypeHierarchyNode node, String value)
rules
- The rules to be appliednode
- A node whose value is to be compared.value
- a string to be comparedpublic TypeHierarchyNode getNodeByValue(String value)
value
- The value to be transformed and matchedpublic String isRedundantSuperSubtype(String supertypeString, String subtypeString)
supertypeString
- subtypeString
- public String showHierarchy(String start)
start
- An initial string; if null, then use the hierarchy title.TypeHierarchyNode.toString(boolean)
public String showHierarchy()