<commit_before># A natural language, as defined by the ISO code.
# === Attributes
# * +alpha2+ - 2-letter code as defined by the ISO standard. Used in URLs.
# * +name+ - the language's common name
# * +plaques_count+ - cached count of plaques
class Language < ApplicationRecord
  has_many :plaques
  has_many :organisations

  validates_presence_of :name, :alpha2
  validates_uniqueness_of :alpha2
  validates_uniqueness_of :name
  scope :most_plaques_order, -> { order("plaques_count DESC nulls last") }

  def flag_icon
    fi = "flag-icon-#{alpha2}"
    fi = 'flag-icon-cz' if alpha2 == 'cs'
    fi = 'flag-icon-de' if alpha2 == 'ed'
    fi = 'flag-icon-by' if alpha2 == 'be'
    fi = 'flag-icon-es-ct' if alpha2 == 'ca'
    fi = 'flag-icon-fr' if alpha2 == 'fe'
    fi = 'flag-icon-it' if alpha2 == 'la'
    fi = 'flag-icon-gb-wls' if alpha2 == 'wl' || alpha2 == 'we'
    fi = 'flag-icon-ie' if alpha2 == 'ga' || alpha2 == 'ge'
    fi = 'flag-icon-my' if alpha2 == 'me'
    fi = 'flag-icon-za' if alpha2 == 'af' || alpha2 == 'af-en'
    fi
  end

  def to_param
    alpha2
  end

  def to_s
    name
  end

  def as_json(options={})
    options = {
      only: [:name, :alpha2, :plaques_count],
      include: { },
      methods: []
    } if !options[:prefixes].blank?
    super(options)
  end
<commit_msg>for dual languages use the first 2 chars<commit_after># A natural language, as defined by the ISO code.
# === Attributes
# * +alpha2+ - 2-letter code as defined by the ISO standard. Used in URLs.
# * +name+ - the language's common name
# * +plaques_count+ - cached count of plaques
class Language < ApplicationRecord
  has_many :plaques
  has_many :organisations

  validates_presence_of :name, :alpha2
  validates_uniqueness_of :alpha2
  validates_uniqueness_of :name
  scope :most_plaques_order, -> { order("plaques_count DESC nulls last") }

  def flag_icon
    alpha2_2 = alpha2[0,2]
    fi = "flag-icon-#{alpha2_2}"
    fi = 'flag-icon-cz' if alpha2_2 == 'cs' # Czech
    fi = 'flag-icon-by' if alpha2_2 == 'be' # Belarusian
    fi = 'flag-icon-es-ct' if alpha2_2 == 'ca' # Catalan
    fi = 'flag-icon-it' if alpha2_2 == 'la' # Latin
    fi = 'flag-icon-gb-wls' if alpha2_2 == 'cy' # Welsh
    fi = 'flag-icon-ie' if alpha2_2 == 'ga' # Gaelic
    fi = 'flag-icon-za' if alpha2_2 == 'af' # Afrikaans
    fi
  end

  def to_param
    alpha2
  end

  def to_s
    name
  end

  def as_json(options={})
    options = {
      only: [:name, :alpha2, :plaques_count],
      include: { },
      methods: []
    } if !options[:prefixes].blank?
    super(options)
  end

{'fraction_non_alphanumeric': 0.14019417475728155, 'fraction_numerical': 0.018640776699029128, 'mean_word_length': 2.956989247311828, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4854739', 'n_tokens_mistral': 990, 'n_tokens_neox': 965, 'n_words': 267}