Blame view
bin/compare.rb
2.13 KB
362b552ee 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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
#!/usr/bin/env ruby require "rubygems" def read_oki() h = Hash.new(false) f = File.open("oki2.txt") f.each do |line| line.chomp! line = line.split(" ") h[ line[0] ] = true end f.close return h end def read_embedding() h = Hash.new(false) f = File.open("embedding/word2vecf_size100_win3.bin") f.each do |line| line.chomp! line = line.split(" ") if line.size > 4 h[ line[0] ] = true end end f.close return h end def embedding(text, h) text.split(" ").each do |w| if w[0] == "#" if h.key?(w.downcase) == false return true end end end return false end def majuscule(text) counter = 0 text.split(" ").each do |w| if w.size > 2 if w.upcase == w counter += 1 end end end if counter > 1 return true end return false end def launch(output_dnn, annotation, type) #hemb = read_embedding() hoki = read_oki() h = Hash.new f = File.open(output_dnn) f.each do |line| line.chomp! line = line.split("\t") h[ line[0] ] = line[1] =begin score = line[1].split(" ") score.map! { |x| x.to_f } ind = score.index( score.max ) if ind == 0 h[ line[0] ] = "negative" end if ind == 1 h[ line[0] ] = "positive" end =end end f.close f = File.open(annotation) f.each do |line| line.chomp! line = line.split("\t") a = line[2] line[2] = line[1] line[1] = a if h.key?( line[0] ) if h[ line[0] ] != line[1] #if hoki.key?(line[0]) == false puts "#{line[0]}\t#{type}\t#{line[1]}\t#{h[ line[0] ]}\t#{line[2]}" #end end end end f.close end def errarg puts "Usage : ./programme.rb" puts "Mickael Rouvier <mickael.rouvier@univ-avignon.fr>" end if ARGV.size == 3 launch(ARGV[0], ARGV[1], ARGV[2]) else errarg end |