Blame view

bin/somme_score.rb 1.07 KB
362b552ee   Rouvier Mickael   upload system
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  #!/usr/bin/env ruby
  
  require "rubygems"
  
  def launch(task, files)
  
      h = Hash.new
      convert = nil
  
      if task == "task1"
          convert = {0 => "negative", 1 => "positive", 2 => "objective", 3 => "mixed"}
      end
      
      if task == "task2"
          convert = {0 => "figurative", 1 => "nonfigurative"}
      end
  
      if task == "task3"
          convert = {0 => "negative", 1 => "positive", 2 => "objective", 3 => "mixed"}
      end
   
      
      files.each do |file|
          f = File.open(file)
          f.each do |line|
              line.chomp!
              line = line.split("\t")
              h[ line[0] ] ||= Array.new(4, 0)
              counter = 0
              line[1].split(" ").each do |x|
                  h[ line[0] ][ counter ] += x.to_f
                  counter += 1
              end
          end
          f.close
      end
  
      h.each do |key, value|
          value.map! { |x| x.to_f/files.size.to_f }
          puts "#{key}\t#{value.join(" ")}"
      end
  
  
  end
  
  
  def errarg
      puts "Usage : ./programme.rb"
      puts "Mickael Rouvier <mickael.rouvier@univ-avignon.fr>"
  end
  
  
  launch(ARGV[0], ARGV[1..-1])