<commit_before>require 'virtus'

##
# Value object for Keyword Statistics
class KeywordStatisticsResult
  include Virtus.model

  attribute :chart_data
  attribute :table_data

  def to_json
    to_hash.to_json
  end
end

##
# Service object to get Keyword Statistics from API
class KeywordStatisticsAPI
  def initialize(api_url)
    @api_url = api_url
    @data = []
  end

  def call
    keyword_stat = KeywordStatisticsResult.new
    response = HTTParty.get(@api_url)
    keyword_list = JSON.parse(response.body)['results']

    keyword_list.each do |word|
      @data << [word['keyword'], word['count']]
    end

    keyword_stat.table_data = keyword_list
    keyword_stat.chart_data = @data
    keyword_stat
  end
end<commit_msg>update keyword chart show number<commit_after>require 'virtus'

##
# Value object for Keyword Statistics
class KeywordStatisticsResult
  include Virtus.model

  attribute :chart_data
  attribute :table_data

  def to_json
    to_hash.to_json
  end
end

##
# Service object to get Keyword Statistics from API
class KeywordStatisticsAPI
  def initialize(api_url)
    @api_url = api_url
    @data = []
  end

  def call
    keyword_stat = KeywordStatisticsResult.new
    response = HTTParty.get(@api_url)
    keyword_list = JSON.parse(response.body)['results']
    keyword_stat.table_data = keyword_list

    if keyword_list.length > 10
      keyword_list = keyword_list[0..9]
    end

    keyword_list.each do |word|
      @data << [word['keyword'], word['count']]
    end

    keyword_stat.chart_data = @data
    keyword_stat
  end
end
{'fraction_non_alphanumeric': 0.08227040816326531, 'fraction_numerical': 0.002551020408163265, 'mean_word_length': 3.6283185840707963, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '889069', 'n_tokens_mistral': 507, 'n_tokens_neox': 491, 'n_words': 125}