Sha256: 59d54194577ad6024710d144fb23ef8d5d13f017b792c0d86c285dae415e63f6

Contents?: true

Size: 1.08 KB

Versions: 389

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

389 entries across 389 versions & 1 rubygems

Version Path
rbbt-util-5.33.19 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.18 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.17 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.16 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.15 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.14 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.13 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.12 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.11 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.9 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.8 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.7 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.6 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.5 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.4 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.3 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.2 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.1 share/rbbt_commands/stat/compare_lists
rbbt-util-5.33.0 share/rbbt_commands/stat/compare_lists
rbbt-util-5.32.30 share/rbbt_commands/stat/compare_lists