de.tuebingen.uni.sfs.germanet.relatedness
Class Path

java.lang.Object
  extended by de.tuebingen.uni.sfs.germanet.relatedness.Path

public class Path
extends java.lang.Object

A class that finds paths from one synset to the root or from one synset to another. Also includes depth, LCS (least common subsumer) and leaf nodes. Constructor takes the starting synset as input. Uses edge-counting.


Constructor Summary
Path(de.tuebingen.uni.sfs.germanet.api.Synset synset)
          Constructor calculates in advance all paths from given synset to root.
 
Method Summary
 java.util.HashSet<de.tuebingen.uni.sfs.germanet.api.Synset> getAllHypernyms()
          Returns a HashSet that includes each synset seen on the different ways from this synset to the root exactly once, including the starting synset and the root.
 java.util.ArrayList<java.util.ArrayList<de.tuebingen.uni.sfs.germanet.api.Synset>> getAllPaths()
          Returns all possible paths from the root to this synset.
 int getDepth()
          Returns the depth of this synset in GermaNet (edge counting).
 int getDistance(Path p)
          Returns the distance between this synset and the synset in the Path argument.
 de.tuebingen.uni.sfs.germanet.api.Synset getInitialSynset()
          Returns the Synset used to initialize this Path object.
 java.util.ArrayList<PathNode> getLeastCommonSubsumer(Path otherPath)
          Returns an ArrayList of least common subsumers (LCS) of this Path object's starting synset and that of the given other Path.
 java.util.ArrayList<de.tuebingen.uni.sfs.germanet.api.Synset> getLeastCommonSubsumerSynset(Path otherPath)
          Returns an ArrayList of Synsets that are LCS of this path object and otherPath
static java.util.List<de.tuebingen.uni.sfs.germanet.api.Synset> getLeaves(de.tuebingen.uni.sfs.germanet.api.GermaNet gnet)
          Finds all leaf nodes of the hierarchy.
 java.util.ArrayList<java.util.ArrayList<de.tuebingen.uni.sfs.germanet.api.Synset>> getShortestPaths()
          Returns the shortest path(s) to this synset (there may be more than one).
 java.util.HashMap<PathNode,java.util.ArrayList<PathNode>> getVisited()
          Returns this Path object's HashMap of nodes seen on different ways up to the root.
 java.util.ArrayList<de.tuebingen.uni.sfs.germanet.api.Synset> pathToAncestorSynset(de.tuebingen.uni.sfs.germanet.api.Synset synset)
          In case that the parameter synset is an ancestor of the current Synset, this method returns the path between the two Synsets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Path

public Path(de.tuebingen.uni.sfs.germanet.api.Synset synset)
Constructor calculates in advance all paths from given synset to root.

Parameters:
synset - The synset for which a path is built.
Method Detail

getDepth

public int getDepth()
Returns the depth of this synset in GermaNet (edge counting).

Returns:
the depth of the synset used to construct this Path object

getShortestPaths

public java.util.ArrayList<java.util.ArrayList<de.tuebingen.uni.sfs.germanet.api.Synset>> getShortestPaths()
Returns the shortest path(s) to this synset (there may be more than one). Backtracks from root to the synset indicated in the constructor.

Returns:
all synsets on the shortest path(s) from the root to this synset

getAllPaths

public java.util.ArrayList<java.util.ArrayList<de.tuebingen.uni.sfs.germanet.api.Synset>> getAllPaths()
Returns all possible paths from the root to this synset. Backtracks from root to the synset indicated in the constructor.

Returns:
all paths from the root to this synset

getLeastCommonSubsumer

public java.util.ArrayList<PathNode> getLeastCommonSubsumer(Path otherPath)
Returns an ArrayList of least common subsumers (LCS) of this Path object's starting synset and that of the given other Path.
The LCS PathNode's index is the distance between the two synsets.

Parameters:
otherPath - The pathNode with which to find the least common subsumer.
Returns:
the PathNode object(s) representing the LCS(s) of the two synsets; PathNode.index = distance between the two path nodes.

getLeastCommonSubsumerSynset

public java.util.ArrayList<de.tuebingen.uni.sfs.germanet.api.Synset> getLeastCommonSubsumerSynset(Path otherPath)
Returns an ArrayList of Synsets that are LCS of this path object and otherPath

Parameters:
otherPath - the path with which the LCS is to be found
Returns:
ArrayList of LCS-Synset

pathToAncestorSynset

public java.util.ArrayList<de.tuebingen.uni.sfs.germanet.api.Synset> pathToAncestorSynset(de.tuebingen.uni.sfs.germanet.api.Synset synset)
In case that the parameter synset is an ancestor of the current Synset, this method returns the path between the two Synsets.

Parameters:
synset - possible ancestor of the current synset
Returns:
ArrayList path between the current synset and the one passed as argument

getAllHypernyms

public java.util.HashSet<de.tuebingen.uni.sfs.germanet.api.Synset> getAllHypernyms()
Returns a HashSet that includes each synset seen on the different ways from this synset to the root exactly once, including the starting synset and the root. More precisely, this combines all keys and values of nested HashMap 'visited' (of PathNodes) into a single map of synsets with no double entries. Starting synset and root node are included only once, even though they may appear on several paths up to the root.

Returns:
HashSet of Synsets that are on this synset's possible paths to the root, including starting point and root

getVisited

public java.util.HashMap<PathNode,java.util.ArrayList<PathNode>> getVisited()
Returns this Path object's HashMap of nodes seen on different ways up to the root. This will contain multiple entries, with the PathNodes differing only in value (distance from the starting point).

Returns:
a HashMap of nodes seen on the way up to the root and their distance from the starting point.

getDistance

public int getDistance(Path p)
Returns the distance between this synset and the synset in the Path argument. Implicit call to getLeastCommonSubsumer: shortest path between two synsets calculated in getLeastCommonSubsumer.

Parameters:
p - the other Path object
Returns:
the distance between the two synsets (edge counting)

getLeaves

public static java.util.List<de.tuebingen.uni.sfs.germanet.api.Synset> getLeaves(de.tuebingen.uni.sfs.germanet.api.GermaNet gnet)
Finds all leaf nodes of the hierarchy.

Parameters:
gnet - Instance of Germanet.
Returns:
A list of all Synsets that are leaf nodes.

getInitialSynset

public de.tuebingen.uni.sfs.germanet.api.Synset getInitialSynset()
Returns the Synset used to initialize this Path object.

Returns:
the initial Synset used to build this Path object