lib/middlemac/private.rb
#--------------------------------------------------------
# Return the complete searchTree.json contents for the
# language of the given resource.
#
# @param [Sitemap::Resource] resource Any resource in
#   the desired language.lproj.
# @return [String] The sitemap in JSON format.
# @!visibility private
#--------------------------------------------------------
Return the complete searchTree.json contents for the
language of the given resource.
Return the complete searchTree . json contents for the language of the given resource .
def hb_search_tree_impl( resource )
    if @hb_search_tree_b
      return @hb_search_tree_b
    end
    word_list = {}
    sitemap = hb_sitemap_impl(resource).select {|r| r.data.title && !r.hb_Section?}
    sitemap.each do |page|
      page.word_frequencies.each do |k,v|
        word_list[k] = {} unless word_list.key?(k)
        word_list[k][page.hb_NavId] = v
      end
    end
    word_trie = Trie.new
    word_list.sort.each { |k, v| word_trie.add k, v }
    @hb_search_tree_b = word_trie.to_h.to_json
  end
def hb_search_tree_impl ( resource ) if @hb_search_tree_b return @hb_search_tree_b end word_list = { } sitemap = hb_sitemap_impl ( resource ) . select { | r | r . data . title && ! r . hb_Section? } sitemap . each do | page | page . word_frequencies . each do | k , v | word_list [ k ] = { } unless word_list . key? ( k ) word_list [ k ] [ page . hb_NavId ] = v end end word_trie = Trie . new word_list . sort . each { | k , v | word_trie . add k , v } @hb_search_tree_b = word_trie . to_h . to_json end
Return the complete searchTree.json contents for the
language of the given resource.
Return the complete searchTree . json contents for the language of the given resource .
# First we need to gather all of the individual resource word frequencies # into a master list of "word" => { "hb_NavId" => weight, ... }. #word_list[k][k] = 0 # Change the structure to a trie so that navigating the nodes is # quite easy.
The sitemap in JSON format.
The sitemap in JSON format .
String
resource
<not_specific>
<not_specific>
resource Any resource in the desired language.lproj.
resource Any resource in the desired language . lproj .
!visibility
None