Add tags

Add tags to the following comment
サンプルデータ(8312件),CPU1.8GHz,3秒で14,456件出力されました。
 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
30
31
32
33
34
35
def jukugo(f)
  r, ht, a, h, t = {}, {}, {}, {}, {}
  open(f) {|fin|
    cnt = 0
    while line = fin.gets
      a[cnt] = line

      h[line[0..1]] = [] if not h[line[0..1]]
      h[line[0..1]] << cnt #--- head

      t[cnt] = line[6..7] #--- tail
      cnt+=1
    end
  }
  t.each{|c,i|
    next if not h[i]
    
    hh = a[c][0..1]
    h[i].each{|k|
      tt = a[k][6..7]
      next if hh == tt
      hhtt = hh+tt
      ht[hhtt] = [] if not ht[hhtt]

      ht[hhtt].each {|m|
        mm = [a[m[0]], a[m[1]], a[c], a[k]].flatten.sort
        r[sprintf("%s\n",mm)] = true if mm.uniq.size == 4
      }
      ht[hhtt] << [c, k]
    }
  }
  r.each {|i|puts i}
end

jukugo(ARGV[0])

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...