MCPcopy Create free account
hub / github.com/google-research/language / __init__

Method __init__

language/emql/eval.py:34–50  ·  view source on GitHub ↗
(self, task, root_dir, data_loader)

Source from the content-addressed store, hash-verified

32 """
33
34 def __init__(self, task, root_dir, data_loader):
35 self.task = task
36 self.data_loader = data_loader
37 # Load answers and hard_answers. Hard answers are defined as
38 # answers that can only be inferred from the test kb that are
39 # not exposed in train kb. Test kb is a superset of train kb.
40 answer_file = root_dir + 'test_ans_%s.pkl' % task
41 hard_answer_file = root_dir + 'test_ans_%s_hard.pkl' % task
42 self.answers = pickle.load(gfile.GFile(answer_file, 'rb'))
43 self.hard_answers = pickle.load(gfile.GFile(hard_answer_file, 'rb'))
44 self.q2b_entity2id = pickle.load(
45 gfile.GFile(root_dir + 'ent2ind.pkl', 'rb'))
46 self.q2b_relation2id = pickle.load(
47 gfile.GFile(root_dir + 'rel2ind.pkl', 'rb'))
48 # Declare metrics.
49 self.total = 0.0
50 self.metrics = {'hits@1': 0.0, 'hits@3': 0.0, 'hits@10': 0.0, 'mrr': 0.0}
51
52 def convert_entid2q2b(self, entid):
53 return self.q2b_entity2id[self.data_loader.id2entity[entid]]

Callers

nothing calls this directly

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected