public function getTopNode(): ?Element {
        $nodes = $this->getTopNodeCandidatesByContents($this->article());

        $nodeCandidates = [];

        $i = 0;
        foreach ($nodes as $node) {
            if ($this->isOkToBoost($node)) {
                $upscore = $this->getTopNodeCandidateScore($node, $i, count($nodes));

                $this->calculateBestNodeCandidateScores($node, $upscore);
                $nodeCandidates = $this->updateBestNodeCandidates($node, $nodeCandidates);

                $i++;
            }
        }

        return $this->getTopNodeByScore($nodeCandidates);
    }
public function getTopNode(): ?Element {
        $nodes = $this->getTopNodeCandidatesByContents($this->article());

        $nodeCandidates = [];

        $i = 0;
        foreach ($nodes as $node) {
            if ($this->isOkToBoost($node)) {
                $upscore = $this->getTopNodeCandidateScore($node, $i, count($nodes));

                $this->calculateBestNodeCandidateScores($node, $upscore);
                $nodeCandidates = $this->updateBestNodeCandidates($node, $nodeCandidates);

                $i++;
            }
        }

        return $this->getTopNodeByScore($nodeCandidates);
    }
public function getTopNode ( ) : ? Element { $ nodes = $ this -> getTopNodeCandidatesByContents ( $ this -> article ( ) ) ; $ nodeCandidates = [ ] ; $ i = 0 ; foreach ( $ nodes as $ node ) { if ( $ this -> isOkToBoost ( $ node ) ) { $ upscore = $ this -> getTopNodeCandidateScore ( $ node , $ i , count ( $ nodes ) ) ; $ this -> calculateBestNodeCandidateScores ( $ node , $ upscore ) ; $ nodeCandidates = $ this -> updateBestNodeCandidates ( $ node , $ nodeCandidates ) ; $ i ++ ; } } return $ this -> getTopNodeByScore ( $ nodeCandidates ) ; }
We're going to start looking for where the clusters of paragraphs are. We'll score a cluster based on the number of stopwords
and the number of consecutive paragraphs together, which should form the cluster of text that this node is around
also store on how high up the paragraphs are, comments are usually at the bottom and should get a lower score

@return Element|null
We re going to start looking for where the clusters of paragraphs are . We ll score a cluster based on the number of stopwords and the number of consecutive paragraphs together which should form the cluster of text that this node is around also store on how high up the paragraphs are comments are usually at the bottom and should get a lower score