Module: CodeModels::InfoExtraction::InfoExtractionFunctionalities

Included in:
CodeModelsAstNode
Defined in:
lib/codemodels/info_extraction.rb

Instance Method Summary collapse

Instance Method Details

#terms_map(language_specific_logic, context = nil) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/codemodels/info_extraction.rb', line 110

def terms_map(language_specific_logic,context=nil)
  # context default to root
  unless context
    context = self
    while context.eContainer
      context = context.eContainer
    end   
  end

  # look into context to see how frequent are certain series of words,
  # frequent series are recognized as composed terms
  terms_breaker = TermsBreaker.from_context(language_specific_logic,context)

  v_map = self.values_map
  terms_map = Hash.new {|h,k| h[k]=0}
  v_map.each do |v,n|
    terms_breaker.terms_in_value(v).each do |t|
      terms_map[t] += n
    end
  end
  terms_map
end

#values_mapObject



106
107
108
# File 'lib/codemodels/info_extraction.rb', line 106

def values_map
  collect_values_with_count_subtree
end