Sha256: 59d54194577ad6024710d144fb23ef8d5d13f017b792c0d86c285dae415e63f6

Contents?: true

Size: 1.08 KB

Versions: 388

Compression:

Stored size: 1.08 KB

Contents

#!/usr/bin/env ruby

require 'rbbt-util'
require 'rbbt/util/simpleopt'

$0 = "rbbt #{$previous_commands*" "} #{ File.basename(__FILE__) }" if $previous_commands

options = SOPT.setup <<EOF

Compare two lists and do confusion matrix

$ #{$0} [options] <filename1> <filename2>

-h--help Print this help
-c--common Print the common entries
-o1--only_1 Print entries only in file 1
-o2--only_2 Print entries only in file 2

EOF
if options[:help]
  if defined? rbbt_usage
    rbbt_usage 
  else
    puts SOPT.doc
  end
  exit 0
end

raise ParameterException, "Please provide two files with the entities to compare" unless ARGV.length == 2
file1, file2 = ARGV

list1 = Open.read(file1).split("\n")
list2 = Open.read(file2).split("\n")

common = list1 & list2
only_1 = list1 - list2
only_2 = list2 - list1

case
when options[:common]
  puts common * "\n"
when options[:only_1]
  puts only_1 * "\n"
when options[:only_2]
  puts only_2 * "\n"
else
  puts "Common: #{common.length}"
  puts "Unique to 1 (#{File.basename(file1)}): #{only_1.length}"
  puts "Unique to 2 (#{File.basename(file2)}): #{only_2.length}"
end

Version data entries

388 entries across 388 versions & 1 rubygems

Version Path
rbbt-util-5.44.1 share/rbbt_commands/stat/compare_lists
rbbt-util-5.43.0 share/rbbt_commands/stat/compare_lists
rbbt-util-5.42.0 share/rbbt_commands/stat/compare_lists
rbbt-util-5.41.1 share/rbbt_commands/stat/compare_lists
rbbt-util-5.41.0 share/rbbt_commands/stat/compare_lists
rbbt-util-5.40.5 share/rbbt_commands/stat/compare_lists
rbbt-util-5.40.4 share/rbbt_commands/stat/compare_lists
rbbt-util-5.40.3 share/rbbt_commands/stat/compare_lists
rbbt-util-5.40.0 share/rbbt_commands/stat/compare_lists
rbbt-util-5.39.0 share/rbbt_commands/stat/compare_lists
rbbt-util-5.38.1 share/rbbt_commands/stat/compare_lists
rbbt-util-5.38.0 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.16 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.15 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.14 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.13 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.12 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.11 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.10 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.9 share/rbbt_commands/stat/compare_lists