class Snuffle::LatentObject
Constants
- DUPLICATE_THRESHOLD
- STOPWORDS
Attributes
object_candidate[RW]
source_methods[RW]
Public Class Methods
extract_candidates(method_defs)
click to toggle source
# File lib/snuffle/latent_object.rb, line 35 def self.extract_candidates(method_defs) stemmer = UEAStemmer.new method_defs.map(&:method_name).inject({}) do |words, method_name| atoms = method_name.split('_') - STOPWORDS atoms = atoms.map{|atom| stemmer.stem(atom.to_s)} atoms.each{ |word| words[word] ||= []; words[word] << method_name } words end end
from(nodes)
click to toggle source
# File lib/snuffle/latent_object.rb, line 24 def self.from(nodes) potential_objects_with_methods(nodes).map do |k,v| new(object_candidate: k, source_methods: v) end end
potential_objects_with_methods(nodes, threshold=DUPLICATE_THRESHOLD)
click to toggle source
# File lib/snuffle/latent_object.rb, line 30 def self.potential_objects_with_methods(nodes, threshold=DUPLICATE_THRESHOLD) method_candidates = Snuffle::Element::MethodDefinition.materialize(nodes.method_defs) extract_candidates(method_candidates).select{|k,v| v.count > threshold } end