<commit_before>class Person < Sequel::Model
  one_to_many :milestones, :order => [:date_from, :date_to]
  many_to_many :documents
  def mentions_in(doc)
    DocumentsPerson.select(:mentions).first(:document_id => doc.id, :person_id => self.id).mentions
  end
  def self.normalize_name(name)
    ActiveSupport::Inflector.transliterate(name.to_s.downcase)
  end
  def self.filter_by_name(name)
    self.filter(:searchable_name => normalize_name(name)) 
  end
  def before_save
    self.searchable_name = self.class.normalize_name(name)
  end
end
Person.plugin :json_serializer
<commit_msg>Filter by the prefix of a person name<commit_after>class Person < Sequel::Model
  one_to_many :milestones, :order => [:date_from, :date_to]
  many_to_many :documents
  def mentions_in(doc)
    DocumentsPerson.select(:mentions).first(:document_id => doc.id, :person_id => self.id).mentions
  end
  def self.normalize_name(name)
    ActiveSupport::Inflector.transliterate(name.to_s.downcase)
  end
  def self.filter_by_name(name,is_prefix=false)
    name +="%" if is_prefix
    self.filter(:searchable_name.like(normalize_name(name)))
  end
  def before_save
    self.searchable_name = self.class.normalize_name(name)
  end
end
Person.plugin :json_serializer

{'fraction_non_alphanumeric': 0.11093247588424437, 'fraction_numerical': 0.0, 'mean_word_length': 5.287878787878788, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '7445467', 'n_tokens_mistral': 442, 'n_tokens_neox': 432, 'n_words': 77}