<commit_before>class Breed < ActiveRecord::Base
  has_many :pups
  attr_accessible :name


  def Breed.is_valid_breed(breed)
    Breed.all_breeds.include? breed
    # !Breed.where(name: breed).empty?
  end

  def Breed.find_breed_by_substr(s)
    Breed.all_breeds.select { |b| (b.downcase.start_with? (s.downcase)) }
  end

  def Breed.find_by_name(breed_name)
    result = Breed.where("name = ?", breed_name).first
    # Added on 7/15/17
    if !result
      return nil
    end
    return result
  end

  #private
  def Breed.all_breeds
    return Breed.select('name').map{ |e| e.name }.to_a
  end
end
<commit_msg>feat:  improved search breed autocomplete<commit_after>class Breed < ActiveRecord::Base
  has_many :pups
  attr_accessible :name


  def Breed.is_valid_breed(breed)
    Breed.all_breeds.include? breed
    # !Breed.where(name: breed).empty?
  end

  def Breed.find_breed_by_substr(s)
    Breed.all_breeds.select { |b| (Breed.contain? b.downcase, s.downcase) }
  end

  def Breed.find_by_name(breed_name)
    result = Breed.where("name = ?", breed_name).first
    # Added on 7/15/17
    if !result
      return nil
    end
    return result
  end
  
  def Breed.contain?(name, str)
    #name.gsub!(/\W+/, '')
    flag = false
    name.split(" ").each do |sub|
      flag = true if sub.starts_with? str
    end
    return flag
  end

  #private
  def Breed.all_breeds
    return Breed.select('name').map{ |e| e.name }.to_a
  end

end

{'fraction_non_alphanumeric': 0.11687413554633472, 'fraction_numerical': 0.006915629322268326, 'mean_word_length': 3.0083102493074794, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '874618', 'n_tokens_mistral': 575, 'n_tokens_neox': 555, 'n_words': 118}