Sha256: 55bbe6dca514f8d87cf2b8724c81b2d3edd3537d673013aea5efc52fb308ddd0
Contents?: true
Size: 1.2 KB
Versions: 7
Compression:
Stored size: 1.2 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].gsub(',', '') if index[1] == 'location' locations << tokens[index[0] - 1].gsub(',', '') 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('.', '') .gsub(',', '') .gsub(':', '') .downcase .split(/[\s-]/) end end end
Version data entries
7 entries across 7 versions & 1 rubygems