summaryrefslogtreecommitdiff
path: root/data/spambase/svm_light_format.rb
blob: 2da4456c7eb4bd261c89b8f067c9a7e75264b16f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env ruby


while line = STDIN.gets
  line.strip!
  a = line.split ','
  label = a[-1].to_i
  label = -1 if label==0
  a = a[0..a.size-2]
  f = []
  a.each_with_index { |i,idx|
     f<<"#{idx+1}:#{i.to_f}"
  }
  puts "#{label} #{f.join(' ')}"
end