Sha256: 8e2351598d6773a0372f62c3e6c6976801812ac641c7ee34b6b4a411a711741f
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
module Support module OfferParser LOCATION_DICT = ['location', 'based'] KEYWORDS = [ 'ruby', 'elixir', 'react', 'remote', 'graphql' ] def self.get_location(content, dict = LOCATION_DICT) indexes = Array.new tokens = get_tokens(content) indexes = dict.map { |q| [tokens.find_index(q), q] } locations = Array.new indexes.each do |index| next if index[0].nil? locations << tokens[index[0] + 1] if index[1] == 'location' locations << tokens[index[0] - 1..index[0] + 2] if index[1] == 'based' end locations.join(' ').capitalize end def self.get_keywords(content, keywords = KEYWORDS) indexes = Array.new tokens = get_tokens(content) indexes = keywords.map { |q| [tokens.find_index(q), q] } keywords = Array.new indexes.each do |index| next if index[0].nil? keywords << tokens[index[0]].gsub(',', '') end keywords.map(&:capitalize).join(', ') end def self.get_tokens(content) content .gsub(/\W+/, ' ') # remove non letters .downcase .split(/[\s-]/) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
remote_job_scraper-0.6.0 | lib/support/offer_parser.rb |
remote_job_scraper-0.5.0 | lib/support/offer_parser.rb |
remote_job_scraper-0.4.4 | lib/support/offer_parser.rb |