blob: 44a7f70f26af20a882d9441a8d6ca78002314d9e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#!/usr/bin/env python3
import fileinput
from math import log
if __name__ == '__main__':
scores = dict()
for line in fileinput.input():
query, dbpediaid, relevance, field, nvalues, nmatches = line.split('\t')
if field not in scores:
scores[field] = 0
scores[field] += float(relevance) * log(1 + int(nmatches)/int(nvalues))
for field, score in scores.items():
print('{}\t{}'.format(field, score))
|