<commit_before>require "stackoverflow/version"
require "stackoverflow/errors"
require "httparty"
require "active_support/core_ext/array/extract_options"
require "active_support/core_ext/hash/except"

module Stackoverflow
  class << self
    attr_accessor :oauth_key
  end

  def self.configure
    yield self
  end

  class Client
    include HTTParty
    attr_reader :access_token

    base_uri 'https://api.stackexchange.com/2.1/'

    def initialize(access_token)
      @access_token = access_token
    end

    # Common options
    #
    # @param options [Hash] Hash containing request options.
    # @option options [Integer] :page
    # @option options [Integer] :pagesize
    # @option options [Timestamp] :fromdate
    # @option options [Timestamp] :todate
    # @option options [String] :order
    # @option options [Integer] :min
    # @option options [Integer] :max
    # @option options [String] :sort

    # Lookup users by name
    #
    # @param query [String] Name or part of the name of the user to look for.
    # @param options [Hash] Hash containing request options.
    # @see https://api.stackexchange.com/docs/users

    def users(query, options = {})
      options ||= {}
      options[:inname] = query

      get "users", normalize_options(options)
    end

    # Get the users identified by ids
    #
    # @param users_ids [Array] Ids of the users.
    # @param options [Hash] Hash containing request options.
    # https://api.stackexchange.com/docs/users-by-ids

    def users_by_ids(users_ids, options = {})
      get "users", users_ids, normalize_options(options)
    end

    # Returns the tags the users identified in ids have been active in.
    #
    # @param users_ids [Array] Ids of the users.
    # @param options [Hash] Hash containing request options.
    # @see https://api.stackexchange.com/docs/tags-on-users

    def users_tags(users_ids, options = {})
      get "users", users_ids, "tags", normalize_options(options)
    end

    def users_associated_accounts(accounts_ids, options = {})
      get "users", accounts_ids, "associated", normalize_options(options).except(:site)
    end

    def users_top_answer_tags(user_id, options = {})
      get "users", user_id, "top-answer-tags", normalize_options(options)
    end

    def users_top_answers(users_ids, tags, options = {})
      get "users", users_ids, "tags", tags, "top-answers", normalize_options(options)<commit_msg>Add top-questions and top-question-tags methods<commit_after>require "stackoverflow/version"
require "stackoverflow/errors"
require "httparty"
require "active_support/core_ext/array/extract_options"
require "active_support/core_ext/hash/except"

module Stackoverflow
  class << self
    attr_accessor :oauth_key
  end

  def self.configure
    yield self
  end

  class Client
    include HTTParty
    attr_reader :access_token

    base_uri 'https://api.stackexchange.com/2.1/'

    def initialize(access_token)
      @access_token = access_token
    end

    # Common options
    #
    # @param options [Hash] Hash containing request options.
    # @option options [Integer] :page
    # @option options [Integer] :pagesize
    # @option options [Timestamp] :fromdate
    # @option options [Timestamp] :todate
    # @option options [String] :order
    # @option options [Integer] :min
    # @option options [Integer] :max
    # @option options [String] :sort

    # Lookup users by name
    #
    # @param query [String] Name or part of the name of the user to look for.
    # @param options [Hash] Hash containing request options.
    # @see https://api.stackexchange.com/docs/users

    def users(query, options = {})
      options ||= {}
      options[:inname] = query

      get "users", normalize_options(options)
    end

    # Get the users identified by ids
    #
    # @param users_ids [Array] Ids of the users.
    # @param options [Hash] Hash containing request options.
    # https://api.stackexchange.com/docs/users-by-ids

    def users_by_ids(users_ids, options = {})
      get "users", users_ids, normalize_options(options)
    end

    # Returns the tags the users identified in ids have been active in.
    #
    # @param users_ids [Array] Ids of the users.
    # @param options [Hash] Hash containing request options.
    # @see https://api.stackexchange.com/docs/tags-on-users

    def users_tags(users_ids, options = {})
      get "users", users_ids, "tags", normalize_options(options)
    end

    def users_associated_accounts(accounts_ids, options = {})
      get "users", accounts_ids, "associated", normalize_options(options).except(:site)
    end

    def users_top_answer_tags(user_id, options = {})
      get "users", user_id, "top-answer-tags", normalize_options(options)
    end

    def users_top_answers(users_ids, tags, options = {})
      get "users", users_ids, "tags", tags, "top-answers", normalize_options(options)
    end

    def users_top_question_tags(user_id, options = {})
      get "users", user_id, "top-question-tags", normalize_options(options)
    end

    def users_top_questions(users_ids, tags, options = {})
      get "users", users_ids, "tags", tags, "top-questions", normalize_options(options)
{'fraction_non_alphanumeric': 0.10773694390715667, 'fraction_numerical': 0.0007736943907156673, 'mean_word_length': 3.3822033898305084, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 8, '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': '2444525', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1566, 'n_words': 442}