<commit_before>module Ltsview
  class Parse

    def initialize(options)
      @ltsv = option_parse options
    end

    def print
      $stdin.each_line do |line|
        LTSV.parse(line).each do |key,val|
          puts "#{key.to_s.magenta}: #{val.cyan}"
        end
      end
    end

    private
     def option_parse(options)
       option = OptionParser.new
       option.on('-f VAL'){ |v| @file = v }
       option.permute!(options)
       options
     end

     def file_load(file_path)
       stream = File.open(file_path, 'r')
       LTSV.parse(stream)
     end

  end
end<commit_msg>add option keys and ignore keys<commit_after>module Ltsview
  class Parse

    def initialize(options)
      @ltsv = option_parse options
    end

    def print
      $stdin.each_line do |line|
        LTSV.parse(line.chomp).each do |key,val|
          puts "#{key.to_s.magenta}: #{val.cyan}" if keys?(key) && !ignore?(key)
        end
      end
    end

    private
     def option_parse(options)
       option = OptionParser.new
       option.on('-f VAL'){ |v| @file = v }
       option.on('-k', '--keys VAL'){ |v| @keys = v.split(',') }
       option.on('-i', '--ignore-key VAL'){ |v| @ignore_key = v.split(',') }
       option.permute!(options)
       options
     end

     def file_load(file_path)
       stream = File.open(file_path, 'r')
       LTSV.parse(stream)
     end

     def keys?(key)
       @keys.nil? || @keys.include?(key.to_s)
     end

     def ignore?(key)
       !@ignore_key.nil? && @ignore_key.include?(key.to_s)
     end

  end
end
{'fraction_non_alphanumeric': 0.13530927835051546, 'fraction_numerical': 0.0, 'mean_word_length': 2.106, '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': '6918877', 'n_tokens_mistral': 551, 'n_tokens_neox': 548, 'n_words': 121}