<commit_before>class MicrosoftTranslator
  CONFIG = YAML.load_file("./config/idiom.yml")
    
  class << self
    def t(value, code)
      value = URI.encode(value)
      # "http://api.microsofttranslator.com/V2/Http.svc/Translate?to=#{code}&text=#{}&appId=<KEY>"
      
      appId = CONFIG["appId"]
      result = Net::HTTP.get(URI.parse("http://api.microsofttranslator.com/V2/Http.svc/Translate?to=#{code}&text=#{value}&appId=#{appId}"))
      
      if result =~ /<string xmlns=\"http:\/\/schemas.microsoft.com\/2003\/10\/Serialization\/\">(.*)<\/string>/
        output = $1
      end
      output.to_s
    end
  end
end<commit_msg>Raise error if over the quota<commit_after>class MicrosoftTranslator
  CONFIG = YAML.load_file("./config/idiom.yml")
    
  class << self
    def t(value, code)
      value = URI.encode(value)
      # "http://api.microsofttranslator.com/V2/Http.svc/Translate?to=#{code}&text=#{}&appId=2CEF8B6B9CA38C6C8355B154C760C28A66E4339F"
      
      appId = CONFIG["appId"]
      url = "http://api.microsofttranslator.com/V2/Http.svc/Translate?to=#{code}&text=#{value}&appId=#{appId}"
      result = Net::HTTP.get(URI.parse(url))
      
      if result =~ /<string xmlns=\"http:\/\/schemas.microsoft.com\/2003\/10\/Serialization\/\">(.*)<\/string>/
        output = $1
      end
      if result =~ /Message: (.*)/
        $stdout.puts(result)
      end
      if result =~ /AppId is over the quota/
        raise "AppId is over the quota"
      end
      output.to_s
    end
  end
end
{'fraction_non_alphanumeric': 0.17748344370860927, 'fraction_numerical': 0.02847682119205298, 'mean_word_length': 2.6943765281173593, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5810778', 'n_tokens_mistral': 580, 'n_tokens_neox': 540, 'n_words': 79}