Sha256: b68857ab2f763092d819c159a8b7687885c037e3a37aebb12b538576552f680d
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module GuessWhoNoFuzzy class Profiler attr_reader :full_name, :email def self.profile!(email) self.new(email).profile! end def initialize(email) @email = email @full_name = "" end def profile! full_name_arr = [] raw_str = email.split("@")[0].upcase strings = raw_str.split(/[^A-Z]/) strings.each do |str| best = { score: 0, parts: [], count: 0 } token_arrays = Tokenizer.tokenize!(str) Scorer.score!(token_arrays) do |score, tokens| is_better = Comparator.better?(score, best[:score], tokens.size, best[:count]) if is_better best = { score: score, parts: tokens, count: tokens.size } end end best[:parts].each do |part| full_name_arr << part.capitalize end end @full_name = full_name_arr.join(" ") self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
guess_who_no_fuzzy-0.2.0 | lib/guess_who_no_fuzzy/profiler.rb |