<commit_before>require "localcallingguide/version"
require 'open-uri'
require 'xmlsimple'

module LocalCallingGuide

  def get_results(url)
    data = open(url).read
    XmlSimple.xml_in(data, 'ForceArray' => false)
  end

  module_function :get_results

  class LocalExchange
    def self.prefixes(exch, dir=1, rconly=0)
      exch_data = LocalCallingGuide.get_results("http://www.localcallingguide.com/xmllocalexch.php?exch=#{exch}&dir=#{dir}&rconly=#{rconly}")
      exch_data['lca-data']['prefix']
    end
  end

  class LocalPrefix
    def self.prefixes(npa, nxx, dir=1)
      prefix_data = LocalCallingGuide.get_results("http://www.localcallingguide.com/xmllocalprefix.php?npa=#{npa}&nxx=#{nxx}&dir=#{dir}")
      prefix_data['lca-data']['prefix']
    end
  end

  class Prefix
    def self.npanxx(npa, nxx)
      prefix_data = LocalCallingGuide.get_results("http://www.localcallingguide.com/xmlprefix.php?npa=#{npa}&nxx=#{nxx}")
      prefix_data['prefixdata']<commit_msg>Added note about KeyToSymbol<commit_after>require "localcallingguide/version"
require 'open-uri'
require 'xmlsimple'

module LocalCallingGuide
  def get_results(url)
    data = open(url).read
    XmlSimple.xml_in(data, 'ForceArray' => false, 'KeyToSymbol' => false)
    # It would be nice to use KeyToSymbol but I have to figure out how to
    # handle hyphened keys, i.e. "company-name"
  end

  module_function :get_results

  class LocalExchange
    def self.prefixes(exch, dir=1, rconly=0)
      exch_data = LocalCallingGuide.get_results("http://www.localcallingguide.com/xmllocalexch.php?exch=#{exch}&dir=#{dir}&rconly=#{rconly}")
      exch_data['lca-data']['prefix']
    end
  end

  class LocalPrefix
    def self.prefixes(npa, nxx, dir=1)
      prefix_data = LocalCallingGuide.get_results("http://www.localcallingguide.com/xmllocalprefix.php?npa=#{npa}&nxx=#{nxx}&dir=#{dir}")
      prefix_data['lca-data']['prefix']
    end
  end

  class Prefix
    def self.npanxx(npa, nxx)
      prefix_data = LocalCallingGuide.get_results("http://www.localcallingguide.com/xmlprefix.php?npa=#{npa}&nxx=#{nxx}")
      prefix_data['prefixdata']
{'fraction_non_alphanumeric': 0.1421152030217186, 'fraction_numerical': 0.0028328611898017, 'mean_word_length': 4.650666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 10}, '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': '2609669', 'n_tokens_mistral': 795, 'n_tokens_neox': 771, 'n_words': 120}