public class TreeRepresentation extends Object implements Representation
Modifier and Type | Field and Description |
---|---|
protected List<TreeNode> |
orderedNodeSetByLabel
The complete set of tree nodes ordered alphabetically by label.
|
protected List<TreeNode> |
orderedNodeSetByProduction
The complete set of tree nodes ordered alphabetically by production
string.
|
protected List<TreeNode> |
orderedNodeSetByProductionIgnoringLeaves
The of non terminal tree nodes ordered alphabetically by production
string.
|
protected TreeNode |
root
The root node of the tree
|
Constructor and Description |
---|
TreeRepresentation() |
TreeRepresentation(TreeNode root)
Build a tree representation from a TreeNode
|
Modifier and Type | Method and Description |
---|---|
TreeRepresentation |
clone() |
boolean |
equals(Object representation) |
List<TreeNode> |
getAllNodes() |
int |
getBranchingFactor() |
int |
getHeight() |
List<TreeNode> |
getLeaves()
Returns all the leaves, i.e.
|
Integer |
getMaxId()
Get the max id within all nodes
|
List<TreeNode> |
getNodesWithContentType(Class<? extends StructureElement> clazz)
Returns all the nodes whose content has type
clazz |
int |
getNumberOfNodes() |
List<TreeNode> |
getOrderedNodeSetByLabel() |
List<TreeNode> |
getOrderedNodeSetByProduction() |
List<TreeNode> |
getOrderedNodeSetByProductionIgnoringLeaves() |
List<TreeNode> |
getPreLeafNodes(int generationHops)
Returns all the nodes that have at least a
generationHops -generation descendant being a leaf
(for instance using generationHops =1 will produce a list of all the fathers of the leaves,
generationHops =2 will produce a list of all the grandfathers of the leaves, etc) |
TreeNode |
getRoot() |
String |
getTextFromData()
Returns a textual representation of the data stored in this
representation
|
String |
getTextualEnrichedTree() |
int |
hashCode() |
boolean |
isCompatible(Representation rep)
Evaluates whether a representation is compatible with this one, e.g.., they have
same type and pass additional checks that are type-dependent
|
void |
setDataFromText(String representationDescription)
Initializes a Representation using its textual description provided in
representationDescription |
String |
toString() |
void |
updateTree()
Updates the tree.
|
protected TreeNode root
protected List<TreeNode> orderedNodeSetByLabel
protected List<TreeNode> orderedNodeSetByProduction
public TreeRepresentation()
public TreeRepresentation(TreeNode root)
root
- Root of the Treepublic TreeRepresentation clone()
public void updateTree()
public Integer getMaxId()
public List<TreeNode> getOrderedNodeSetByLabel()
public List<TreeNode> getOrderedNodeSetByProduction()
public List<TreeNode> getOrderedNodeSetByProductionIgnoringLeaves()
public TreeNode getRoot()
public String getTextFromData()
Representation
getTextFromData
in interface Representation
public void setDataFromText(String representationDescription) throws Exception
Representation
representationDescription
setDataFromText
in interface Representation
representationDescription
- the textual description of the representation to be
initializedException
public String getTextualEnrichedTree()
public List<TreeNode> getNodesWithContentType(Class<? extends StructureElement> clazz)
clazz
clazz
- the type of the contentclazz
public List<TreeNode> getLeaves()
public List<TreeNode> getPreLeafNodes(int generationHops)
generationHops
-generation descendant being a leaf
(for instance using generationHops
=1 will produce a list of all the fathers of the leaves,
generationHops
=2 will produce a list of all the grandfathers of the leaves, etc)generationHops
- the number of generations from the leavesgenerationHops
-generation descendant being a leafpublic boolean isCompatible(Representation rep)
Representation
isCompatible
in interface Representation
rep
- the representation to be compared with this onepublic int getNumberOfNodes()
public int getHeight()
public int getBranchingFactor()
Copyright © 2018 Semantic Analytics Group @ Uniroma2. All rights reserved.