<commit_before># encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

$KCODE = 'UTF-8' unless RUBY_VERSION >= '1.9.0'

require 'yaml'
require 'date'
require 'time'
require 'fileutils'

# gems
require 'forwardable'

require 'twitter_cldr/version'

Enumerator = Enumerable::Enumerator unless defined?(Enumerator)

module TwitterCldr

  autoload :Formatters,    'twitter_cldr/formatters'
  autoload :Collation,     'twitter_cldr/collation'
  autoload :Localized,     'twitter_cldr/localized'
  autoload :Normalization, 'twitter_cldr/normalization'
  autoload :Resources,     'twitter_cldr/resources'
  autoload :Shared,        'twitter_cldr/shared'
  autoload :Tokenizers,    'twitter_cldr/tokenizers'
  autoload :Utils,         'twitter_cldr/utils'

  extend SingleForwardable

  # version of CLDR that was used for generating YAML files in the resources/ directory
  CLDR_VERSION = '21.0' # release date: 2012-02-10

  DEFAULT_LOCALE = :en
  DEFAULT_CALENDAR_TYPE = :gregorian

  RESOURCES_DIR = File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'resources')

  # maps twitter locales to cldr locales
  TWITTER_LOCALE_MAP = {
      :msa     => :ms,
      :'zh-cn' => :zh,
      :'zh-tw' => :'zh-Hant',
      :no      => :nb
  }

  # maps cldr locales to twitter locales
  CLDR_LOCALE_MAP = TWITTER_LOCALE_MAP.invert

  def_delegator :resources, :get_resource
  def_delegator :resources, :get_locale_resource

  class << self

    attr_accessor :locale

    def resources
      @resources ||= TwitterCldr::Resources::Loader.new
    end

    def locale=(new_locale)
      @locale = new_locale
    end

    def locale
      locale = supported_locale?(@locale) ? @locale : find_fallback
      locale = DEFAULT_LOCALE if locale.to_s.empty?
      (supported_locale?(locale) ? locale : DEFAULT_LOCALE).to_sym<commit_msg>Switching to attr_writer for locale getter/setter<commit_after># encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

$KCODE = 'UTF-8' unless RUBY_VERSION >= '1.9.0'

require 'yaml'
require 'date'
require 'time'
require 'fileutils'

# gems
require 'forwardable'

require 'twitter_cldr/version'

Enumerator = Enumerable::Enumerator unless defined?(Enumerator)

module TwitterCldr

  autoload :Formatters,    'twitter_cldr/formatters'
  autoload :Collation,     'twitter_cldr/collation'
  autoload :Localized,     'twitter_cldr/localized'
  autoload :Normalization, 'twitter_cldr/normalization'
  autoload :Resources,     'twitter_cldr/resources'
  autoload :Shared,        'twitter_cldr/shared'
  autoload :Tokenizers,    'twitter_cldr/tokenizers'
  autoload :Utils,         'twitter_cldr/utils'

  extend SingleForwardable

  # version of CLDR that was used for generating YAML files in the resources/ directory
  CLDR_VERSION = '21.0' # release date: 2012-02-10

  DEFAULT_LOCALE = :en
  DEFAULT_CALENDAR_TYPE = :gregorian

  RESOURCES_DIR = File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'resources')

  # maps twitter locales to cldr locales
  TWITTER_LOCALE_MAP = {
      :msa     => :ms,
      :'zh-cn' => :zh,
      :'zh-tw' => :'zh-Hant',
      :no      => :nb
  }

  # maps cldr locales to twitter locales
  CLDR_LOCALE_MAP = TWITTER_LOCALE_MAP.invert

  def_delegator :resources, :get_resource
  def_delegator :resources, :get_locale_resource

  class << self

    attr_writer :locale

    def resources
      @resources ||= TwitterCldr::Resources::Loader.new
    end

    def locale
      locale = supported_locale?(@locale) ? @locale : find_fallback
      locale = DEFAULT_LOCALE if locale.to_s.empty?
      (supported_locale?(locale) ? locale : DEFAULT_LOCALE).to_sym
{'fraction_non_alphanumeric': 0.1052347544522396, 'fraction_numerical': 0.011872638963842417, 'mean_word_length': 3.8268229166666665, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4469548', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1287, 'n_words': 279}