forked from DebadityaPal/RoBERTa-NL2SQL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
corenlp_local.py
30 lines (22 loc) · 889 Bytes
/
corenlp_local.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
def get_g_wvi_bert_from_g_wvi_corenlp(wh_to_wp_index, g_wvi_corenlp):
"""
Generate SQuAD style start and end index of wv in nlu. Index is for of after WordPiece tokenization.
Assumption: where_str always presents in the nlu.
"""
g_wvi = []
for b, g_wvi_corenlp1 in enumerate(g_wvi_corenlp):
wh_to_wp_index1 = wh_to_wp_index[b]
g_wvi1 = []
for i_wn, g_wvi_corenlp11 in enumerate(g_wvi_corenlp1):
st_idx, ed_idx = g_wvi_corenlp11
st_wp_idx = wh_to_wp_index1[st_idx]
ed_wp_idx = wh_to_wp_index1[ed_idx]
g_wvi11 = [st_wp_idx, ed_wp_idx]
g_wvi1.append(g_wvi11)
g_wvi.append(g_wvi1)
return g_wvi
def get_g_wvi_corenlp(t):
g_wvi_corenlp = []
for t1 in t:
g_wvi_corenlp.append( t1['wvi_corenlp'] )
return g_wvi_corenlp