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.37.9 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.8 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.6 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.4 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.3 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.1 share/rbbt_commands/stat/compare_lists
rbbt-util-5.37.0 share/rbbt_commands/stat/compare_lists
rbbt-util-5.36.0 share/rbbt_commands/stat/compare_lists
rbbt-util-5.35.4 share/rbbt_commands/stat/compare_lists
rbbt-util-5.35.3 share/rbbt_commands/stat/compare_lists
rbbt-util-5.35.2 share/rbbt_commands/stat/compare_lists
rbbt-util-5.35.1 share/rbbt_commands/stat/compare_lists
rbbt-util-5.34.27 share/rbbt_commands/stat/compare_lists
rbbt-util-5.34.26 share/rbbt_commands/stat/compare_lists
rbbt-util-5.34.25 share/rbbt_commands/stat/compare_lists
rbbt-util-5.34.24 share/rbbt_commands/stat/compare_lists
rbbt-util-5.34.23 share/rbbt_commands/stat/compare_lists
rbbt-util-5.34.22 share/rbbt_commands/stat/compare_lists
rbbt-util-5.34.21 share/rbbt_commands/stat/compare_lists
rbbt-util-5.34.20 share/rbbt_commands/stat/compare_lists