Class PathFinder


  • public class PathFinder
    extends Object
    • 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 path
        nodeDistance - 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 node
        bestGuessesCount - 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 score
        bestGuessesCount - the size of the result collection, i.e. the number of similar nodes to return
        guessCap - 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.