blob: e915f3b0f994149f4c683e06025337de2a36aa11 (
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
30
31
32
33
34
35
36
37
38
39
|
#!/usr/bin/env ruby
lists = []
0.upto(21) { lists << [] }
cached = []
while line = STDIN.gets
line.strip!
a = line.split ','
cached << a
1.upto(22) { |i|
lists[i-1] << a[i]
}
end
lists.each { |list| list.uniq! }
fmaps = []
global_fid = 1
0.upto(21) { fmaps << {} }
lists.each_with_index { |list, i|
list.each_with_index { |fval, j|
fmaps[i][fval] = global_fid
global_fid += 1
}
}
cached.each { |i|
label = i[0]
if label == 'e'
label = 1
elsif label == 'p'
label = -1
else
next
end
f = i[1..22]
a = []
f.each_with_index { |j,idx| a << "#{fmaps[idx][j]}:1.0" }
puts "#{label} #{a.join ' '}"
}
|