<commit_before>#https://api.edamam.com/search?q=chicken&app_id=${81a71c4e}&app_key=${<KEY>}
require 'json'
require "rest-client"
require 'pry'
response = RestClient.get('https://api.edamam.com/search?q=chicken&app_id=81a71c4e&app_key=<KEY>')
data = JSON.parse(response)
binding.pry
puts "EOF"

data["hits"][0]["ingredients"]

#ingredient list
data["hits"][0]["recipe"]["ingredients"]
#recipe title
data["hits"][0]["recipe"]["label"]<commit_msg>fleshed out a way to strip certain words for the ingredients, trying to clean up the data so when we add to our db it won't have extraneous words or characters in the name of the ingredient<commit_after>#https://api.edamam.com/search?q=chicken&app_id=${81a71c4e}&app_key=${<KEY>}
require 'json'
require "rest-client"
require 'pry'
require 'pp'
response = RestClient.get('https://api.edamam.com/search?q=chicken&app_id=81a71c4e&app_key=<KEY>')
data = JSON.parse(response)
#binding.pry
puts "EOF"
class String
  def strip_ingredient_list

    self.split(/[\s,()]/).reject do |string|
      string.include?("tablespoon")  || string.include?("teaspoon") || string.include?("cup") || /\A\d+\z/.match(string) ||  string.include?("(") || string.include?(")") || string.include?(",") || string.include?("/") || string.include("-")
    end.join(' ')
  end
end

#data["hits"][0]["ingredients"]

#ingredient list
#data["hits"][0]["recipe"]["ingredients"]
#individual ingredients
#data["hits"][0]["recipe"]["ingredients"].collect{|ingredient| ingredient["text"]}
#recipe title
#data["hits"][0]["recipe"]["label"]


#filling a sample array to test our regex to extract ingredient names
sample_array = []
data["hits"].each do |hit|

  sample_array += hit["recipe"]["ingredients"].collect{|ingredient| ingredient["text"]}
end
puts sample_array
binding.pry
puts "EOF"

single_test = sample_array[1].split(/[\s,()]/)
single_test = single_test.reject do |string|
  string.include?("tablespoon")  || /\A\d+\z/.match(string) ||  string.include?("(") || string.include?(")") || string.include?(",")
end

puts sample_array.collect{|ingredient_list| ingredient_list.strip_ingredient_list}
{'fraction_non_alphanumeric': 0.2019914651493599, 'fraction_numerical': 0.013276434329065908, 'mean_word_length': 6.785977859778598, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2385834', 'n_tokens_mistral': 788, 'n_tokens_neox': 772, 'n_words': 142}