khulnasoft
commited on
Commit
•
047c047
1
Parent(s):
ca502dc
Create reVerbReader.py
Browse files
evaluation_data/carb/oie_readers/reVerbReader.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from oie_readers.oieReader import OieReader
|
2 |
+
from oie_readers.extraction import Extraction
|
3 |
+
|
4 |
+
class ReVerbReader(OieReader):
|
5 |
+
|
6 |
+
def __init__(self):
|
7 |
+
self.inputSents = [sent.strip() for sent in open(ReVerbReader.RAW_SENTS_FILE).readlines()]
|
8 |
+
self.name = 'ReVerb'
|
9 |
+
|
10 |
+
def read(self, fn):
|
11 |
+
d = {}
|
12 |
+
with open(fn) as fin:
|
13 |
+
for line in fin:
|
14 |
+
data = line.strip().split('\t')
|
15 |
+
arg1, rel, arg2 = data[2:5]
|
16 |
+
confidence = data[11]
|
17 |
+
text = self.inputSents[int(data[1])-1]
|
18 |
+
|
19 |
+
curExtraction = Extraction(pred = rel, sent = text, confidence = float(confidence))
|
20 |
+
curExtraction.addArg(arg1)
|
21 |
+
curExtraction.addArg(arg2)
|
22 |
+
d[text] = d.get(text, []) + [curExtraction]
|
23 |
+
self.oie = d
|
24 |
+
|
25 |
+
# ReVerb requires a different files from which to get the input sentences
|
26 |
+
# Relative to repo root folder
|
27 |
+
RAW_SENTS_FILE = './raw_sentences/all.txt'
|