Skip to content

Commit

Permalink
Make priorities recursive.
Browse files Browse the repository at this point in the history
It was previously possible to get a more exact match that was
lower-scoring, because scores only took into account the immediate
ancestor when scoring. This commit resolves that situation by making the
scoring recursively walk through all the ancestors and include all their
scores in the current node's score, meaning deeper nodes are always
going to be more valuable than shallower nodes.
  • Loading branch information
paddycarver committed Jul 21, 2018
1 parent e4289cd commit 84314e3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (b *branch) score() float64 {
}
score = score / float64(b.depth+1)
if b.parent != nil {
score += b.parent.priority
score += b.parent.score()
}
return score
}
Expand Down

0 comments on commit 84314e3

Please sign in to comment.