<commit_before>require "thor"
require "open-uri"
require "nokogiri"
require "colored"
require "dcs/debian/version"
require "dcs/debian/helper"

module Dcs
  module Debian

    class Command < Thor

      desc "control KEYWORD", ""
      def control(arg)
        client = Searcher.new
        client.pagination("control", arg) do |context|
          puts sprintf("%s (%s)",
                       context[:path].bold.white_on_green,
                       context[:url].white_on_blue)
          puts context[:pre].gsub(/#{arg}/, '\&'.red_on_yellow)
        end
      end

      desc "changelog KEYWORD", ""
      def changelog(arg)
        client = Searcher.new
        client.pagination("changelog", arg) do |context|
          puts sprintf("%s (%s)",
                       context[:path].bold.white_on_green,
                       context[:url].white_on_blue)
          puts context[:pre].gsub(/#{arg}/, '\&'.red_on_yellow)
        end
      end

      desc "rules KEYWORD", ""
      def rules(arg)
        client = Searcher.new
        client.pagination("rules", arg) do |context|
          puts sprintf("%s (%s)",
                       context[:path].bold.white_on_green,
                       context[:url].white_on_blue)
          puts context[:pre].gsub(/#{arg}/, '\&'.red_on_yellow)
        end
      end

      def method_missing(id, *arguments)
        client = Searcher.new
        client.pagination(id.to_s, arguments[0]) do |context|
          puts sprintf("%s (%s)",
                       context[:path].bold.white_on_green,
                       context[:url].white_on_blue)
          puts context[:pre].gsub(/#{arguments[0]}/, '\&'.red_on_yellow)
        end
      end

    end<commit_msg>Simplify<commit_after>require "thor"
require "open-uri"
require "nokogiri"
require "colored"
require "dcs/debian/version"
require "dcs/debian/helper"

module Dcs
  module Debian

    class Command < Thor

      desc "control KEYWORD", ""
      def control(arg)
        dcs_search("control", arg)
      end

      desc "changelog KEYWORD", ""
      def changelog(arg)
        dcs_search("changelog", arg)
      end

      desc "rules KEYWORD", ""
      def rules(arg)
        dcs_search("rules", arg)
      end

      private

      def dcs_search(file, keyword)
        client = Searcher.new
        client.pagination(file, keyword) do |context|
          puts sprintf("%s (%s)",
                       context[:path].bold.white_on_green,
                       context[:url].white_on_blue)
          puts context[:pre].gsub(/#{keyword}/, '\&'.red_on_yellow)
        end
      end

      def method_missing(id, *arguments)
        dcs_search(id.to_s, arguments[0])
      end

    end
{'fraction_non_alphanumeric': 0.12885258076494616, 'fraction_numerical': 0.0011139992573338284, 'mean_word_length': 1.947483588621444, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5151437', 'n_tokens_mistral': 833, 'n_tokens_neox': 813, 'n_words': 171}