Skip to content

Commit

Permalink
Finishing parsing Gold for every Claim
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrojlazevedo committed Mar 15, 2020
1 parent f865dff commit 9e0a821
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
15 changes: 3 additions & 12 deletions metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@
lines['claim'] = lines['claim'].replace("-RRB-", " ) ")
train_concatenate.append(lines)

# this evidence addition is irrelevant
info_by_id = dict((d['id'], dict(d, index=index)) for (index, d) in enumerate(train_set))
for lines in train_predictions_file:
#print(lines['id'])
lines['evidence'] = info_by_id.get(lines['id'])['evidence']
train_prediction.append(lines)

# All claims
stop = 0

# List with dicts with all important data
'''
id : id of the claim
Expand Down Expand Up @@ -93,10 +83,11 @@
total_claim = 0
for claim in train_relevant:
_id = claim['id']
gold_dict = gold_data.get(_id)
_claim = Claim.find_by_id(_id)[0]

# no search is needed... no information on gold dict about retrieval
if not gold_dict['verifiable']:
print(_claim.id)
if not _claim.verifiable:
continue

# document analysis
Expand Down
7 changes: 7 additions & 0 deletions metrics/claim.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from metrics.evidence import Evidence
from collections import defaultdict


class Claim:
id_index = defaultdict(list)

def __init__(self, _id, name, verifiable):
self.id = _id
Expand All @@ -11,6 +13,7 @@ def __init__(self, _id, name, verifiable):
else:
self.verifiable = 0
self.gold_evidence = []
Claim.id_index[_id].append(self)

def add_gold_evidence(self, document, evidence, line_num):
evidence = Evidence(document, evidence, line_num)
Expand All @@ -31,3 +34,7 @@ def get_gold_documents(self):
for e in self.gold_evidence:
docs |= e.documents
return docs

@classmethod
def find_by_id(cls, _id):
return Claim.id_index[_id]

0 comments on commit 9e0a821

Please sign in to comment.