<commit_before>module RGreek

module Parse
  def self.included(klass)
    puts klass
    klass.extend(ClassMethods)
  end
  
  module ClassMethods
     include Reflector

    def find_parses_hashed_by_lemma(word)
      parses = find_parses(word)
      parses.inject({}) do |parses_hashed_by_lemma, parse| #assumes parses sorted by lemma_id      
        lemma = lemma_class.find_by_parse(parse)
        parses_hashed_by_lemma[lemma] ? parses_hashed_by_lemma[lemma] << parse : parses_hashed_by_lemma[lemma] = [parse]
        parses_hashed_by_lemma
      end
    end
  
    def find_parses(word)
      if Transcoder.has_accents?(word)
        find_all_by_form(word)
      else
        find_all_by_bare_form(word)
      end
    end
  end#EOM

end#EOM
  
class GreekParse < ActiveRecord::Base       
  include Parse
  #lemma_class :greek_lemma
  belongs_to :greek_lemma
  default_scope order("lemma_id asc").order("dialects desc").order("morph_code asc")
  
  def english_morph_code
    MorphCode.convert_to_english(morph_code)
  end
  
  def to_s
    "#{id}: #{form}, #{english_morph_code}, lemma_id: #{lemma_id}"
  end  
end#EOC
  
end#EOM<commit_msg>refactored common parse code into parse to allow for creation of latin parse without duplication<commit_after>module RGreek

module Parse

  def self.included(klass)
    klass.extend(ClassMethods)
    klass.class_eval do
      default_scope order("lemma_id asc").order("dialects desc").order("morph_code asc")             
    end    
  end
    
  def english_morph_code
    MorphCode.convert_to_english(morph_code)
  end
  
  def to_s
    "#{id}: #{form}, #{english_morph_code}, lemma_id: #{lemma_id}"
  end 
  
  module ClassMethods
     include Reflector

    def find_parses_hashed_by_lemma(word)
      parses = find_parses(word)
      parses.inject({}) do |parses_hashed_by_lemma, parse| #assumes parses sorted by lemma_id      
        lemma = lemma_class.find_by_parse(parse)
        parses_hashed_by_lemma[lemma] ? parses_hashed_by_lemma[lemma] << parse : parses_hashed_by_lemma[lemma] = [parse]
        parses_hashed_by_lemma
      end
    end
  
    def find_parses(word)
      if Transcoder.has_accents?(word)
        find_all_by_form(word)
      else
        find_all_by_bare_form(word)
      end
    end
  end#EOM

end#EOM
  
class GreekParse < ActiveRecord::Base       
  include Parse
  belongs_to :greek_lemma
end#EOC

class LatinParse < ActiveRecord::Base       
  include Parse
  belongs_to :latin_lemma
end#EOC
  
end#EOM
{'fraction_non_alphanumeric': 0.07794294897549217, 'fraction_numerical': 0.0, 'mean_word_length': 3.24190800681431, 'pattern_counts': {'":': 0, '<': 10, '<?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': '1044932', 'n_tokens_mistral': 894, 'n_tokens_neox': 883, 'n_words': 172}