<commit_before>require 'json'

module SgPostcode
  class Response
    def initialize(raw_data)
      @raw_data = JSON.parse(raw_data)
    end

    # build the data hash
    # may use Builder object to contruct the output data
    #
    #
    def data
      @raw_data['results'][0]['formatted_address']
    end
  end
end<commit_msg>feat: return output as a son<commit_after>require 'json'

module SgPostcode
  class Response
    def initialize(raw_data, response_type = :json)
      @raw_data = JSON.parse(raw_data)
      @response_type = response_type
    end

    # build the data hash
    # may use Builder object to contruct the output data
    #
    def data
      case @response_type
      when :json
        ResponseBuilder::JsonOutput.new(@raw_data).data
      else
        nil
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07019704433497537, 'fraction_numerical': 0.0012315270935960591, 'mean_word_length': 2.5973451327433628, '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': '4135142', 'n_tokens_mistral': 251, 'n_tokens_neox': 249, 'n_words': 75}