<commit_before>module Core
  class ExternalPost
    class ScheduledAnalysisService
      class Sentiment140Api
        include HTTParty
        base_uri "http://www.sentiment140.com/api"
        debug_output if Rails.env.development?

        ALLOWED_LANGUAGES = %w(en es).freeze

        def classify_analyses(data:, language:)
          body = {
            data: data,
            language: sanitize_language(language)
          }
          self.class.post(
            "/bulkClassifyJson?#{app_id}",
            body: body.to_json
          )
        end

        private

        def sanitize_language(lang)
          unless ALLOWED_LANGUAGES.include?(lang)
            return "auto"
          end
          lang
        end

        def app_id
          client_email = Rails.application.secrets.sentiment140_email
          "appid=#{client_email}"
        end
      end
    end
  end
end<commit_msg>encode sentiment140 email<commit_after>module Core
  class ExternalPost
    class ScheduledAnalysisService
      class Sentiment140Api
        include HTTParty
        base_uri "http://www.sentiment140.com/api"
        debug_output if Rails.env.development?

        ALLOWED_LANGUAGES = %w(en es).freeze

        def classify_analyses(data:, language:)
          body = {
            data: data,
            language: sanitize_language(language)
          }
          self.class.post(
            "/bulkClassifyJson?#{app_id}",
            body: body.to_json
          )
        end

        private

        def sanitize_language(lang)
          unless ALLOWED_LANGUAGES.include?(lang)
            return "auto"
          end
          lang
        end

        def app_id
          client_email = Rails.application.secrets.sentiment140_email
          "appid=#{URI.encode_www_form_component(client_email)}"
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07069616837560712, 'fraction_numerical': 0.011332973556395036, 'mean_word_length': 1.718475073313783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, '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': '3838442', 'n_tokens_mistral': 561, 'n_tokens_neox': 516, 'n_words': 103}