Sha256: 215f8b2ceb922c05882a34bdc4efa11f73bf4e56876629207d19c2b74f66976e
Contents?: true
Size: 504 Bytes
Versions: 3
Compression:
Stored size: 504 Bytes
Contents
module DeviceMap class UserAgent def initialize(user_agent) @user_agent = user_agent end def keyword_ngrams(size) keywords = @user_agent.split(/[\s;\-_\/()\[\]\\]+/) normalized_keywords = Keyword.normalize(keywords) normalized_keywords.flat_map.with_index do |keyword, i| size.times.map do |j| next_keywords = normalized_keywords[i + 1..-1] || [] Array(keyword).concat next_keywords.take(j) end end.uniq end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
device_map-0.1.2 | lib/device_map/user_agent.rb |
device_map-0.1.1 | lib/device_map/user_agent.rb |
device_map-0.1.0 | lib/device_map/user_agent.rb |