-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfileGenerator.py
129 lines (123 loc) · 4.49 KB
/
fileGenerator.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# MIT License
#
# Copyright (c) [2018] [Gang Ling ([email protected]),
# Yuliya Lierler ([email protected])]
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import pprint
# print drs in asp format
def drs_to_asp(drs_dict):
print('%', end=' ')
print(', '.join(drs_dict['entity']), end=', ')
print(', '.join(drs_dict['event']))
print('%', end=' ')
print('=='*30)
count = 0
key_list = [k for k in drs_dict.keys()]
for key in key_list:
items = drs_dict[key]
if key == 'entity' or key == 'event':
print('\n')
for i in items:
print(key, end='')
print('(', end='')
print(i, end='')
print(').', end=' ')
count += 1
if count == 4:
print()
count = 0
elif key == 'eventArgument':
print('\n')
count = 0
for (e, t, r) in items:
print(key, end='')
print('(', end='')
print(e, end=', ')
print('\"' + t + '\"', end=', ')
print(r, end='')
print(').', end=' ')
count += 1
if count == 3:
print()
count = 0
elif key == 'eventTime':
print('\n')
count = 0
for (e, t) in items:
print(key, end='')
print('(', end='')
print(e, end=', ')
print(t, end='')
print(').', end=' ')
count += 1
if count == 5:
print()
count = 0
else:
print('\n')
count = 0
for (e, v) in items:
print(key, end='')
print('(', end='')
print(e, end=', ')
print('\"' + v + '\"', end='')
print(').', end=' ')
count += 1
if count == 4:
print()
count = 0
def output_vbsrl(m_lst):
pp = pprint.PrettyPrinter(indent=4)
count = 1
for sentence in m_lst:
for word_dct in sentence:
if word_dct['ID'] == '1':
print()
print("SENTENCE " + str(count) + ":", end='\n')
count += 1
pp.pprint(word_dct)
print()
# print verbnet srl table
def print_table(m_lst):
dct_keys = m_lst[0][0].keys()
for key in dct_keys:
print("{:10s}\t".format(key), end="")
for lst in m_lst:
print('')
for sub_dct3 in lst:
print('')
for key in dct_keys:
if key == 'vn-pb':
for item in sub_dct3.get(key):
if item[0] == 'vn':
print('{};'.format(item[1]), end='')
elif item[0] != '_':
count = 0
for k in item:
if count == 0:
print('{}'.format(k), end=":")
count += 1
else:
print('{}'.format(k), end="; ")
count = 0
else:
print('{:5s}'.format(item[0]), end="")
else:
print("{:10s}\t".format(sub_dct3.get(key)), end="")