f = File.open("P_annotation.tsv","r:utf-8") single_annotated = Hash.new(0) multi_annotated = Hash.new(0) headers = {} f.each_line.with_index do |line, index| line1 = line.strip.split("\t") if index == 0 line1.each.with_index do |header, header_index| headers[header] = header_index end #STDERR.puts headers else annotated_by = [] for annotator in [1, 3, 6, 7, 8, 9, 10, 11] if line1[headers[annotator.to_s]] != "" annotated_by << annotator end end #STDERR.puts "#{annotated_by}" #STDERR.puts "#{annotated_by.length}" if annotated_by.length == 1 single_annotated[annotated_by[0]] += 1 else for annotator in annotated_by multi_annotated[annotator] += 1 end end end #if index == 10 # break #end end #STDERR.puts single_annotated STDOUT.puts "Annotator\tsingle\tmulti\ttotal" single_annotated.keys.each do |annotator| STDOUT.puts "#{annotator}\t#{single_annotated[annotator]}\t#{multi_annotated[annotator]}\t#{single_annotated[annotator]+multi_annotated[annotator]}" end