class CompareCatalogues def initialize argv @vfile, @wfile = argv @db = {} end def import filename, sym $deferr.puts "loading #{filename} #{sym}" File.open(filename) {|fp| for line in fp ahl = line.chomp cccc = ahl.sub(/^.*,/, '') next if /^[HYP]/ === ahl place = case cccc when /^LFVP/ then "RA4" when /^RP/ then "RA5" when /^(BI|HA|FH|MJ|O[JKLS]|IA|IR|RU|S[OX])/ then "RA6" when /^(D[EK]|MN|BA|BC|U[AT])/ then "RA2" # DEMS DKPY BABJ MNUB when /^[DFGH]/ then "RA1" when /^[ORV]/ then "RA2" when /^S/ then "RA3" when /^[CKMPT]/ then "RA4" when /^[ANW]/ then "RA5" when /^[ELUYZ]/ then "RA6" else cccc end prod = case ahl when /^([DHOY]|[IK][A-Z][A-Z])/ then $1 + '*' else ahl[0,2] + '*' end for key in [place + ' *', [place, prod].join(' '), "* #{prod}"] @db[key] = {} unless @db.include?(key) t = @db[key] t[ahl] = {} unless t.include?(ahl) t[ahl][sym] = true end end } end def report puts "#RA DATA, BOTH, VolC1, GISC" puts "# , , ONLY, ONLY" for key in @db.keys.sort t = @db[key] v = w = vw = 0 for ahl, symtab in t if symtab[:vc1] then if symtab[:wis] then vw += 1 else v += 1 end else if symtab[:wis] then w += 1 else raise ahl end end end printf("%-8s,%6u,%6u,%6u\n", key, vw, v, w) end end def run import(@vfile, :vc1) import(@wfile, :wis) report end end CompareCatalogues.new(ARGV).run