<commit_before>require 'sinatra/base'
require 'sinatra/flash'
# require 'chartkick' # Create beautiful Javascript charts with one line of Ruby
require 'rack-flash'
require 'httparty'
require 'slim'

require 'active_support'
require 'active_support/core_ext'

# Sinatra controller
class ApplicationController < Sinatra::Base
  use Rack::MethodOverride
  use Rack::Session::Pool
  use Rack::Flash
  register Sinatra::Flash # to be deleted
  helpers ApplicationHelpers

  set :views, File.expand_path('../../views', __FILE__)
  set :public_folder, File.expand_path('../../public', __FILE__)

  configure :production, :development do
    enable :logging
  end

  # Web functions
  get_root = lambda do
    session[:hot_keywords] ||= ['Facebook', 'commerce', 'Paypal', 'eBay']
    # Keywords should change later

    @added_word = params['added_word']
    @deleted_word = params['deleted_word']

    add_keyword(@added_word) if @added_word
    delete_keyword(@deleted_word) if @deleted_word

    slim :trend
  end
  # get '/article/filter?'
  get_article_with_filter = lambda do
    session[:hot_keywords] ||= ['Facebook', 'commerce', 'Paypal', 'eBay']
    @tags = params['tags']
    @author = params['author']
    @title = params['title']
    # @tags = 'facebook'  #testing

    options = { headers: { 'Content-Type' => 'application/json' }, query: { :tags => @tags } }
    @article = HTTParty.get(api_url('article/filter?'), options)<commit_msg>get the first one keyword trend<commit_after>require 'sinatra/base'
require 'sinatra/flash'
# require 'chartkick' # Create beautiful Javascript charts with one line of Ruby
require 'rack-flash'
require 'httparty'
require 'slim'

require 'active_support'
require 'active_support/core_ext'

# Sinatra controller
class ApplicationController < Sinatra::Base
  use Rack::MethodOverride
  use Rack::Session::Pool
  use Rack::Flash
  register Sinatra::Flash # to be deleted
  helpers ApplicationHelpers

  set :views, File.expand_path('../../views', __FILE__)
  set :public_folder, File.expand_path('../../public', __FILE__)

  configure :production, :development do
    enable :logging
  end

  # Web functions
  get_root = lambda do
    session[:hot_keywords] ||= ['Facebook', 'commerce', 'Paypal', 'eBay']
    # Keywords should change later

    @added_word = params['added_word']
    @deleted_word = params['deleted_word']

    add_keyword(@added_word) if @added_word
    delete_keyword(@deleted_word) if @deleted_word

    slim :trend
  end
  # get '/article/filter?'
  get_article_with_filter = lambda do
    session[:hot_keywords] ||= ['Facebook', 'commerce', 'Paypal', 'eBay']
    @tags = params['tags']
    @author = params['author']
    @title = params['title']
    @tags = session[:hot_keywords][0]  #testing

    options = { headers: { 'Content-Type' => 'application/json' }, query: { :tags => @tags } }
    @article = HTTParty.get(api_url('article/filter?'), options)
{'fraction_non_alphanumeric': 0.137221269296741, 'fraction_numerical': 0.00034305317324185246, 'mean_word_length': 4.470919324577861, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '655260', 'n_tokens_mistral': 917, 'n_tokens_neox': 890, 'n_words': 232}