Package com.epam.healenium.treecomparing
Class PathFinder
- java.lang.Object
-
- com.epam.healenium.treecomparing.PathFinder
-
public class PathFinder extends Object
-
-
Constructor Summary
Constructors Constructor Description PathFinder(PathDistance pathDistance, NodeDistance nodeDistance)Creates a path finder which operates certain algorithms of distance by path and by node comparing
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Scored<Node>>find(Path path, Node newSource, int bestGuessesCount)Finds the list of nodes that most likely are our searched one, ordered by likeness descendingNodefindNearest(Path path, Node newSource)Finds the nearest node that most likely is our searched oneAbstractMap.SimpleImmutableEntry<Integer,Map<Double,List<AbstractMap.SimpleImmutableEntry<Node,Integer>>>>findScoresToNodes(Path path, Node newSource)Finds the Map of all nodes that most likely are our searched one, ordered by likeness descendingList<Scored<Node>>getSortedNodes(Map<Double,List<AbstractMap.SimpleImmutableEntry<Node,Integer>>> scoresToNodes, int bestGuessesCount, double guessCap)Sort the Map of all nodes that most likely are our searched one, ordered by likeness descending
-
-
-
Constructor Detail
-
PathFinder
public PathFinder(PathDistance pathDistance, NodeDistance nodeDistance)
Creates a path finder which operates certain algorithms of distance by path and by node comparing- Parameters:
pathDistance- an algorithm to evaluate node likeness by their pathnodeDistance- an algorithm to evaluate node likeness by content
-
-
Method Detail
-
findNearest
public Node findNearest(Path path, Node newSource)
Finds the nearest node that most likely is our searched one- Parameters:
path- a collection of nodes that represents the total searched node path; the first node is html tag, the last node is the searched node. We assume that all nodes in the path have their full info.newSource- the parsed DOM of the changed page in which we will look for the searched node- Returns:
- most likely node or null if there isn't any
-
find
public List<Scored<Node>> find(Path path, Node newSource, int bestGuessesCount)
Finds the list of nodes that most likely are our searched one, ordered by likeness descending- Parameters:
path- a collection of nodes that represents the total searched node path; the first node is html tag, the last node is the searched node. We assume that all nodes in the path have their full info.newSource- the parsed DOM of the changed page in which we will look for the searched nodebestGuessesCount- the size of the result collection, i.e. the number of similar nodes to return- Returns:
- a list of probably similar nodes, ordered by likeness descending, with the size of bestGuessesCount
-
findScoresToNodes
public AbstractMap.SimpleImmutableEntry<Integer,Map<Double,List<AbstractMap.SimpleImmutableEntry<Node,Integer>>>> findScoresToNodes(Path path, Node newSource)
Finds the Map of all nodes that most likely are our searched one, ordered by likeness descending- Parameters:
path- a collection of nodes that represents the total searched node path; the first node is html tag, the last node is the searched node. We assume that all nodes in the path have their full info.newSource- the parsed DOM of the changed page in which we will look for the searched node- Returns:
- a Map of probably similar nodes, with the size of bestGuessesCount.
-
getSortedNodes
public List<Scored<Node>> getSortedNodes(Map<Double,List<AbstractMap.SimpleImmutableEntry<Node,Integer>>> scoresToNodes, int bestGuessesCount, double guessCap)
Sort the Map of all nodes that most likely are our searched one, ordered by likeness descending- Parameters:
scoresToNodes- the source Map of nodes with scorebestGuessesCount- the size of the result collection, i.e. the number of similar nodes to returnguessCap- a min score, that path must exceed to be selected- Returns:
- a list of probably similar nodes, ordered by likeness descending, with the size of bestGuessesCount.
-
-