-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_old_network.py
48 lines (34 loc) · 1.41 KB
/
create_old_network.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# ################################################################################
# ## Copyright (C) Gaurav Dass - All Rights Reserved
# ## Unauthorized copying of this file, via any medium is strictly prohibited
# ## Proprietary and confidential
# ## Written by Gaurav Dass <dassgaurav93@gmail.com>, January 2020
#
# ################################################################################
"""
Extract causes effects from girju's verb list given a list of causes and effects from previous network, create new network
"""
import crelib
import jsonlines
import sys
from crelib.old_verbs import verbs,reverse_verbs
ceinpath = sys.argv[1]
csoutpath = sys.argv[2]
csoutpath2 = sys.argv[3]
ceoutpath = sys.argv[4]
newdxname = sys.argv[5]
crelib.parameter_config.verbs = verbs;
crelib.parameter_config.reverse_verbs = reverse_verbs;
print('processing ce pairs from original network ......')
with jsonlines.open(ceinpath,'r') as filer:
with open(csoutpath,'w') as filew:
for cdict in filer:
filew.write(cdict['evidences'][0].strip() + '\n')
print('sentences written')
crelib.get_causal_sentences.get_causal_sentences_lines(csoutpath,csoutpath2)
print('causal sentences obtained')
crelib.get_causes_effects.get_causes_effects_line(csoutpath2,ceoutpath)
print('cause effect pairs obtained')
crelib.index_pairs.do_indexing_for_causes_effects_batch(ceoutpath,newdxname,'cause_effect_pairs')
print('index created')