Skip to content

Instantly share code, notes, and snippets.

@akdh
Created August 20, 2015 17:12
Show Gist options
  • Save akdh/516c7a9612c9fcd7a7a3 to your computer and use it in GitHub Desktop.
Save akdh/516c7a9612c9fcd7a7a3 to your computer and use it in GitHub Desktop.
Converts custom CSV to qrel format
import csv
import sys
VOTE_THRESHOLD = 2
topics = {}
next_topic = 900
for row in csv.reader(sys.stdin):
if row[1] == 'blah':
continue
if not row[2].endswith('_vote'):
continue
if row[1] not in topics:
topics[row[1]] = next_topic
next_topic += 1
print("%d\t0\t%s\t%d" % (topics[row[1]], row[2].split('_')[0], int(int(row[3]) > VOTE_THRESHOLD)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment