<commit_before>module SgPostcode
  module LongLatConverter
    # Convert an array of SG Postcode
    #
    # @return an array contains long, lat
    #
    # @params
    #   - postcodes: array[String] of postcode
    #   - opts: options in hash, supports
    #     + response_type: default is :json, check the response folder
    #     + service_provider: :Google is default, check services folder
    #
    # @example
    #  postcodes = ['238432', '247964']
    #  SgPostCode::LongLatConverter.convert(postcodes)
    # TODO options
    def self.convert(postcodes, opts = {})
      postcodes.map { |postcode| place_info(postcode) }
    end

    def self.place_info(postcode)
      send_geo_request(postcode, host: :Google).data
    end

    # Send request to host, and return the response
    #
    # @return
    #
    # @params
    #   postcode
    #   host: default is Google
    #
    # @example
    # SgPostcode::LongLatConverter.send_geo_request("230000", host: :Google)
    #
    def self.send_geo_request(postcode, host: :Google)
      return nil if Module.const_defined? host

      Response.new(
        Google.new(postcode).request,
        response_type: :json
      )
    end
  end
end
<commit_msg>docs: add document for place_info method<commit_after>module SgPostcode
  module LongLatConverter
    # Convert an array of SG Postcode
    #
    # @return an array contains long, lat
    #
    # @params
    #   - postcodes: array[String] of postcode
    #   - opts: options in hash, supports
    #     + response_type: default is :json, check the response folder
    #     + service_provider: :Google is default, check services folder
    #
    # @example
    #  postcodes = ['238432', '247964']
    #  SgPostCode::LongLatConverter.convert(postcodes)
    # TODO options
    def self.convert(postcodes, opts = {})
      postcodes.map { |postcode| place_info(postcode) }
    end

    # Request info from host for a postcode
    #
    # @return hash of info, check
    #  response/config.rb to see the info fields
    #
    # @params: postcode number [String]
    def self.place_info(postcode)
      send_geo_request(postcode, host: :Google).data
    end

    # Send request to host, and return the response
    #
    # @return
    #
    # @params
    #   postcode
    #   host: default is Google
    #
    # @example
    # SgPostcode::LongLatConverter.send_geo_request("230000", host: :Google)
    #
    def self.send_geo_request(postcode, host: :Google)
      return nil if Module.const_defined? host

      Response.new(
        Google.new(postcode).request,
        response_type: :json
      )
    end
  end
end

{'fraction_non_alphanumeric': 0.09413109756097561, 'fraction_numerical': 0.013719512195121951, 'mean_word_length': 2.5520974289580516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3863643', 'n_tokens_mistral': 842, 'n_tokens_neox': 815, 'n_words': 219}