Sha256: ba4a1e9d757b7ea1d10ce620310a3b049a0208fa4bdd9226bf6fdc562c67a73e
Contents?: true
Size: 561 Bytes
Versions: 10
Compression:
Stored size: 561 Bytes
Contents
module TextRank module RankFilter ## # A rank filter which sorts the results by value ## class SortByValue # @param descending [boolean] whether to sort in descending order def initialize(descending: true) @descending = !!descending end # Perform the filter on the ranks # @param ranks [Hash<String, Float>] the results of the PageRank algorithm # @return [Hash<String, Float>] def filter!(ranks, **_) Hash[ranks.sort_by { |_, v| @descending ? -v : v }] end end end end
Version data entries
10 entries across 10 versions & 1 rubygems