khulnasoft
commited on
Commit
•
ca502dc
1
Parent(s):
73bc8f5
Create split_corpus.py
Browse files
evaluation_data/carb/oie_readers/split_corpus.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
""" Usage:
|
2 |
+
split_corpus --corpus=CORPUS_FN --reader=READER --in=INPUT_FN --out=OUTPUT_FN
|
3 |
+
|
4 |
+
Split OIE extractions according to raw sentences.
|
5 |
+
This is used in order to split a large file into train, dev and test.
|
6 |
+
|
7 |
+
READER - points out which oie reader to use (see dictionary for possible entries)
|
8 |
+
"""
|
9 |
+
from clausieReader import ClausieReader
|
10 |
+
from ollieReader import OllieReader
|
11 |
+
from openieFourReader import OpenieFourReader
|
12 |
+
from propsReader import PropSReader
|
13 |
+
from reVerbReader import ReVerbReader
|
14 |
+
from stanfordReader import StanfordReader
|
15 |
+
from docopt import docopt
|
16 |
+
import logging
|
17 |
+
logging.basicConfig(level = logging.INFO)
|
18 |
+
|
19 |
+
available_readers = {
|
20 |
+
"clausie": ClausieReader,
|
21 |
+
"ollie": OllieReader,
|
22 |
+
"openie4": OpenieFourReader,
|
23 |
+
"props": PropSReader,
|
24 |
+
"reverb": ReVerbReader,
|
25 |
+
"stanford": StanfordReader
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
if __name__ == "__main__":
|
30 |
+
args = docopt(__doc__)
|
31 |
+
inp = args["--in"]
|
32 |
+
out = args["--out"]
|
33 |
+
corpus = args["--corpus"]
|
34 |
+
reader = available_readers[args["--reader"]]()
|
35 |
+
reader.read(inp)
|
36 |
+
reader.split_to_corpus(corpus,
|
37 |
+
out)
|