<commit_before># `region` is the country, `sub_region1` is the state, and `sug_region2`
# is the city.
class Location < ActiveRecord::Base
  belongs_to :identity
  validate :at_least_one
  
  has_many :location_phones, :dependent => :destroy
  accepts_nested_attributes_for :location_phones, allow_destroy: true, reject_if: :all_blank
  
  def at_least_one
    if [name, address1].reject(&:blank?).size == 0
      errors.add("", "Name or address required")
    end
  end
  
  def region_name
    if !region.nil?
      Carmen::Country.coded(region).official_name
    else
      nil
    end
  end
  
  def display
    result = name
    if result.blank?
      result = address1
    end
    result
  end

  def sub_region1_name
    if !region.blank? && !sub_region1.blank?
      reg = Carmen::Country.coded(region)
      if reg.subregions.length > 0
        subregion = reg.subregions.coded(sub_region1)
        if !subregion.nil?
          subregion.name
        else
          sub_region1<commit_msg>Add city to location display<commit_after># `region` is the country, `sub_region1` is the state, and `sub_region2`
# is the city.
class Location < ActiveRecord::Base
  belongs_to :identity
  validate :at_least_one
  
  has_many :location_phones, :dependent => :destroy
  accepts_nested_attributes_for :location_phones, allow_destroy: true, reject_if: :all_blank
  
  def at_least_one
    if [name, address1].reject(&:blank?).size == 0
      errors.add("", "Name or address required")
    end
  end
  
  def region_name
    if !region.nil?
      Carmen::Country.coded(region).official_name
    else
      nil
    end
  end
  
  def display
    result = name
    if result.blank?
      result = address1
    end
    if !sub_region2.blank?
      result += ", " + sub_region2
    end
    result
  end

  def sub_region1_name
    if !region.blank? && !sub_region1.blank?
      reg = Carmen::Country.coded(region)
      if reg.subregions.length > 0
        subregion = reg.subregions.coded(sub_region1)
        if !subregion.nil?
          subregion.name
        else
          sub_region1
{'fraction_non_alphanumeric': 0.09082172032676598, 'fraction_numerical': 0.010571840461316675, 'mean_word_length': 2.7649186256781193, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '732372', 'n_tokens_mistral': 695, 'n_tokens_neox': 676, 'n_words': 170}