<commit_before>class Recipe < ActiveRecord::Base
	has_many :ingredients, through: :recipe_ingredients
  has_many :recipe_ingredients

  has_many :users, through: :user_recipes
  has_many :user_recipes

	#I MADE A CHANGE TESTING
	def self.find_by_ingredient_list(ingredient_list)
    fridge_ingredients = Set.new(ingredient_list)

		Recipe.all.select do |recipe|
			# recipe.ingredients == ingredient_list
			#simplifying for testing
			recipe_ingredients = Set.new(recipe.ingredients)
      recipe_ingredients.subset?(fridge_ingredients) && !recipe_ingredients.empty?
		end
	end

	def self.find_exact_match_by_ingredient_list
	end

	def self.create_new_recipe(recipe_title)
		while self.exists?(:title => recipe_title)
  		puts "This recipe already exists in the database! Please enter a different recipe title:"
  		recipe_title = gets.chomp
		end
		self.create(title: recipe_title)
	end

	def add_ingredients_to_recipe(recipe_ingredients)
		recipe_ingredients.each do |ingredient_name|
			ingredient = Ingredient.find_or_create_by(name: ingredient_name)
  		self.ingredients << ingredient
		end
	end

	def print_recipe()
		puts "Name: #{self.title}"
		self.ingredients.each_with_index do |ingredient, index|
		  puts "#{index + 1}: #{ingredient.name}"
		end
	end



end<commit_msg>edited 'add_ingredients_to_recipe' to find ingredients that are 'like' existing ingredients<commit_after>class Recipe < ActiveRecord::Base
	has_many :ingredients, through: :recipe_ingredients
  has_many :recipe_ingredients

  has_many :users, through: :user_recipes
  has_many :user_recipes

	#I MADE A CHANGE TESTING
	def self.find_by_ingredient_list(ingredient_list)
    fridge_ingredients = Set.new(ingredient_list)

		Recipe.all.select do |recipe|
			# recipe.ingredients == ingredient_list
			#simplifying for testing
			recipe_ingredients = Set.new(recipe.ingredients)
      recipe_ingredients.subset?(fridge_ingredients) && !recipe_ingredients.empty?
		end
	end

	def self.find_exact_match_by_ingredient_list
	end

	def self.create_new_recipe(recipe_title)
		while self.exists?(:title => recipe_title)
  		puts "This recipe already exists in the database! Please enter a different recipe title:"
  		recipe_title = gets.chomp
		end
		self.create(title: recipe_title)
	end

	def add_ingredients_to_recipe(recipe_ingredients)
    recipe_ingredients.each do |ingredient_name|
      ingredient = Ingredient.where("name LIKE ?", "%#{ingredient_name}%")
      puts ingredient

      if ingredient.any?
        self.ingredients << ingredient
        self.save
      else
        self.ingredients << Ingredient.create(name: ingredient_name)
        self.save
        puts "ELSEEEE"
      end
    end

    # ingredient = Ingredient.find_or_create_by(name: ingredient_name)
    # self.ingredients << ingredient
  end

	def print_recipe()
		puts "Name: #{self.title}"
		self.ingredients.each_with_index do |ingredient, index|
		  puts "#{index + 1}: #{ingredient.name}"
		end
	end



end
{'fraction_non_alphanumeric': 0.08395144976399191, 'fraction_numerical': 0.0006743088334457181, 'mean_word_length': 4.474169741697417, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '6137414', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1005, 'n_words': 215}