summaryrefslogtreecommitdiff
path: root/overlapping_rules/rules_cross_product.rb
blob: 649a94c956f3a2deb464222c737093e152d3cdd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env ruby

require_relative './util.rb'


STDOUT.sync = true
approx_count = 7430933/192

i = 0
prev_id = nil
accumulate = []
read_rules_from_file2(STDIN, 'stdin') { |id,r|
  i += 1
  if id != prev_id
    if prev_id
      accumulate.sort_by! { |i| i.id }#.uniq { |i| i.id }
      accumulate.each_with_index { |a,j|
        accumulate[j+1..accumulate.size].each_with_index { |b,k|
          STDOUT.write "#{a.id}+#{b.id}\t#{a.to_s} <<<>>> #{b.to_s}\n"
        }
      }
      accumulate.clear
    end
    prev_id = id
  end
  accumulate << r
  STDERR.write "reporter:status:cross product ##{i} #{((i*100.0)/approx_count).round 2}%\n"
}