31
31
import corenlp
32
32
import drs2
33
33
import fileGenerator
34
+ import configparser
34
35
35
36
# lth output file
36
37
output_file = None
39
40
40
41
41
42
# The method to call and run lth tool with a input file
42
- def process_lth (file ):
43
+ def process_lth (file , lth_path ):
43
44
44
45
# store text2drs tool's path
45
46
text2_drs_path = os .getcwd ()
46
47
47
- lth_path = text2_drs_path + '/lth_srl/'
48
-
49
48
# switch current dictionary to lth folder
50
49
os .chdir (lth_path )
51
50
@@ -97,9 +96,8 @@ def process_lth(file):
97
96
98
97
# process input file by running corenlp through command line
99
98
# output file format can be choose from text, xml, json
100
- def process_corenlp (file ):
99
+ def process_corenlp (file , corenlp_path ):
101
100
text2_drs_path = os .getcwd ()
102
- corenlp_path = text2_drs_path + '/stanford-corenlp-full-2016-10-31/'
103
101
os .chdir (corenlp_path )
104
102
output_path = text2_drs_path + '/corenlp_Outputs/'
105
103
output_format = 'xml'
@@ -116,11 +114,20 @@ def process_corenlp(file):
116
114
117
115
118
116
def main ():
117
+ config = configparser .RawConfigParser ()
118
+
119
119
parser = argparse .ArgumentParser ()
120
+ parser .add_argument ("config" , help = 'given full path of config file' , type = str )
120
121
parser .add_argument ("input" , help = 'given full path of input file' , type = str )
121
122
args = parser .parse_args ()
123
+
124
+ config .read (args .config )
122
125
input_file = args .input
123
- process_lth (input_file )
126
+
127
+ lth_path = config .get ('LTH' , 'Path' )
128
+ corenlp_path = config .get ('CoreNLP' , 'Path' )
129
+
130
+ process_lth (input_file , lth_path )
124
131
125
132
# read lth output file and store in lth_output
126
133
lth_output = None
@@ -145,7 +152,7 @@ def main():
145
152
sys .stdout = orig_stdout
146
153
f .close ()
147
154
148
- corenlp_output_path = process_corenlp (input_file )
155
+ corenlp_output_path = process_corenlp (input_file , corenlp_path )
149
156
corenlp_output = None
150
157
try :
151
158
corenlp_output = ET .parse (corenlp_output_path )
0 commit comments