<commit_before># Splits a national number into a fixed size NDC and rest.
#
module Phony
  module Countries
    
    # Returns an anonymous fixed size ndc / format country handler.
    #
    def self.fixed size, options = {}
      options.merge! :ndc_length => size
      Phony::Country.fixed options
    end
    
    # TODO
    #
    def self.with_cc cc
      mapping[cc.size][cc.to_s]
    end
    
    # Defines a mapping of country code to all splitters/formatters.
    #
    # Note: The above fixed helper is used.
    #       In some cases, we have explicit countries defined.
    #
    # Note: Many taken from http://en.wikipedia.org/wiki/Telephone_numbering_plan.
    #
    def self.mapping
      {
        1 => {
          '0' => fixed(1), # reserved
          '1' => fixed(3,  # USA, Canada, etc.
                       :local_format => [3, 4]
                 ),
          
          # Kazakhstan (Republic of) & Russian Federation
          # http://en.wikipedia.org/wiki/Telephone_numbers_in_Russia
          #
          '7' => fixed(3,
                       :local_format => [3, 2, 2]
                 ),
        },
        2 => {
          '20' => Countries::Egypt,
          '27' => fixed(2,  # South Africa
                        :local_format => [3, 4]
                  ),
                  
          '30' => Countries::Greece,
          '31' => Countries::Netherlands,
          '32' => Countries::Belgium,
          '33' => fixed(1,  # France
                        :local_format         => [2, 2, 2, 2],
                        :service_ndcs         => %w{8}
                        # :special_ndcs => {
                        #   :service => %w{8},
                        #   :mobile  => %w{6 7}
                        # }
                  ),
          '34' => fixed(2, # Spain
                    :local_format => [3, 4]
                  ),
          '36' => Countries::Hungary,
          '39' => Countries::Italy,

          '40' => Countries::Romania,
          '41' => fixed(2,  # Switzerland (Confederation of)
                        :local_format         => [3, 2, 2],
                        :service_local_format => [3, 3],
                        :service_ndcs         => %w{800 840 842 844 848}
                        # :special_ndcs => {
                        #   :service => %w{800 840 842 844 848},
                        #   :mobile  => %w{74 76 77 78 79}
                        # }
                  ),
          '43' => Countries::Austria,
          '44' => fixed(2), # TODO United Kingdom of Great Britain and Northern Ireland
          '45' => fixed(2,  # Denmark
                        :local_format => [2, 2, 2]
                  ),
          '46' => Countries::Sweden,
          '47' => fixed(4,  # Norway<commit_msg>+ faking denmark<commit_after># Splits a national number into a fixed size NDC and rest.
#
module Phony
  module Countries
    
    # Returns an anonymous fixed size ndc / format country handler.
    #
    def self.fixed size, options = {}
      options.merge! :ndc_length => size
      Phony::Country.fixed options
    end
    
    # TODO
    #
    def self.with_cc cc
      mapping[cc.size][cc.to_s]
    end
    
    # Defines a mapping of country code to all splitters/formatters.
    #
    # Note: The above fixed helper is used.
    #       In some cases, we have explicit countries defined.
    #
    # Note: Many taken from http://en.wikipedia.org/wiki/Telephone_numbering_plan.
    #
    def self.mapping
      {
        1 => {
          '0' => fixed(1), # reserved
          '1' => fixed(3,  # USA, Canada, etc.
                       :local_format => [3, 4]
                 ),
          
          # Kazakhstan (Republic of) & Russian Federation
          # http://en.wikipedia.org/wiki/Telephone_numbers_in_Russia
          #
          '7' => fixed(3,
                       :local_format => [3, 2, 2]
                 ),
        },
        2 => {
          '20' => Countries::Egypt,
          '27' => fixed(2,  # South Africa
                        :local_format => [3, 4]
                  ),
                  
          '30' => Countries::Greece,
          '31' => Countries::Netherlands,
          '32' => Countries::Belgium,
          '33' => fixed(1,  # France
                        :local_format         => [2, 2, 2, 2],
                        :service_ndcs         => %w{8}
                        # :special_ndcs => {
                        #   :service => %w{8},
                        #   :mobile  => %w{6 7}
                        # }
                  ),
          '34' => fixed(2, # Spain
                    :local_format => [3, 4]
                  ),
          '36' => Countries::Hungary,
          '39' => Countries::Italy,

          '40' => Countries::Romania,
          '41' => fixed(2,  # Switzerland (Confederation of)
                        :local_format         => [3, 2, 2],
                        :service_local_format => [3, 3],
                        :service_ndcs         => %w{800 840 842 844 848}
                        # :special_ndcs => {
                        #   :service => %w{800 840 842 844 848},
                        #   :mobile  => %w{74 76 77 78 79}
                        # }
                  ),
          '43' => Countries::Austria,
          '44' => fixed(2), # TODO United Kingdom of Great Britain and Northern Ireland
          '45' => fixed(2,  # Denmark
                        :local_format => [2, 2, 2]
                  ), # Denmark has no NDC, but 4 groups of 2 digits. I'm faking it here.
          '46' => Countries::Sweden,
          '47' => fixed(4,  # Norway
{'fraction_non_alphanumeric': 0.12271029699448693, 'fraction_numerical': 0.040192068290947895, 'mean_word_length': 1.1531393568147015, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 79, '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': '1985889', 'n_tokens_mistral': 1776, 'n_tokens_neox': 1585, 'n_words': 407}