<commit_before># frozen_string_literal: true

# Name category concerns
module NameCategorable
  extend ActiveSupport::Concern
  include NameCategories

  def name_type_must_match_category
    return if NameType.option_ids_for_category(category).include?(name_type_id)
    errors.add(:name_type_id,
               "Wrong name type for category! Category: #{category} vs
               name type: #{name_type.name}.")
  end

  def category
    change_category_to.present? ? change_category_to : raw_category
  end

  RAW_CATEGORY = {
    "autonym" => NameCategories::SCIENTIFIC_CATEGORY,
    "hybrid formula unknown 2nd parent" =>
    NameCategories::SCIENTIFIC_HYBRID_FORMULA_UNKNOWN_2ND_PARENT_CATEGORY,
    "named hybrid" => NameCategories::SCIENTIFIC_CATEGORY,
    "named hybrid autonym" => NameCategories::SCIENTIFIC_CATEGORY,
    "sanctioned" => NameCategories::SCIENTIFIC_CATEGORY,
    "scientific" => NameCategories::SCIENTIFIC_CATEGORY,
    "phrase name" => NameCategories::PHRASE,
    "cultivar hybrid formula" =>
    NameCategories::SCIENTIFIC_HYBRID_FORMULA_CATEGORY,
    "graft/chimera" => NameCategories::SCIENTIFIC_HYBRID_FORMULA_CATEGORY,
    "hybrid" => NameCategories::SCIENTIFIC_HYBRID_FORMULA_CATEGORY,
    "hybrid autonym" => NameCategories::SCIENTIFIC_HYBRID_FORMULA_CATEGORY,<commit_msg>Added 'candidatus' to the name category hash.<commit_after># frozen_string_literal: true

# Name category concerns
module NameCategorable
  extend ActiveSupport::Concern
  include NameCategories

  def name_type_must_match_category
    return if NameType.option_ids_for_category(category).include?(name_type_id)
    errors.add(:name_type_id,
               "Wrong name type for category! Category: #{category} vs
               name type: #{name_type.name}.")
  end

  def category
    change_category_to.present? ? change_category_to : raw_category
  end

  RAW_CATEGORY = {
    "autonym" => NameCategories::SCIENTIFIC_CATEGORY,
    "hybrid formula unknown 2nd parent" =>
    NameCategories::SCIENTIFIC_HYBRID_FORMULA_UNKNOWN_2ND_PARENT_CATEGORY,
    "named hybrid" => NameCategories::SCIENTIFIC_CATEGORY,
    "named hybrid autonym" => NameCategories::SCIENTIFIC_CATEGORY,
    "sanctioned" => NameCategories::SCIENTIFIC_CATEGORY,
    "scientific" => NameCategories::SCIENTIFIC_CATEGORY,
    "candidatus" => NameCategories::SCIENTIFIC_CATEGORY,
    "phrase name" => NameCategories::PHRASE,
    "cultivar hybrid formula" =>
    NameCategories::SCIENTIFIC_HYBRID_FORMULA_CATEGORY,
    "graft/chimera" => NameCategories::SCIENTIFIC_HYBRID_FORMULA_CATEGORY,
    "hybrid" => NameCategories::SCIENTIFIC_HYBRID_FORMULA_CATEGORY,
    "hybrid autonym" => NameCategories::SCIENTIFIC_HYBRID_FORMULA_CATEGORY,
{'fraction_non_alphanumeric': 0.09020332717190388, 'fraction_numerical': 0.0014787430683918669, 'mean_word_length': 5.397163120567376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, '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': '1545287', 'n_tokens_mistral': 959, 'n_tokens_neox': 890, 'n_words': 147}