Update bert_align.py

This commit is contained in:
nlpfun
2021-11-30 08:31:57 +08:00
parent 2658ab60bf
commit ba1f308b1f

View File

@@ -196,7 +196,8 @@ def second_pass_align(src_vecs,
def second_back_track(i, j, b, search_path, a_types):
alignment = []
while ( i !=0 and j != 0 ):
#while ( i !=0 and j != 0 ):
while ( 1 ):
j_offset = j - search_path[i][0]
a = b[i][j_offset]
s = a_types[a][0]
@@ -208,6 +209,7 @@ def second_back_track(i, j, b, search_path, a_types):
i = i-s
j = j-t
if i == 0 and j == 0:
return alignment[::-1]
@nb.jit(nopython=True, fastmath=True, cache=True)
@@ -306,7 +308,8 @@ def first_back_track(i, j, b, search_path, a_types):
alignment: list of tuples for 1-1 alignments.
"""
alignment = []
while ( i !=0 and j != 0 ):
#while ( i !=0 and j != 0 ):
while ( 1 ):
j_offset = j - search_path[i][0]
a = b[i][j_offset]
s = a_types[a][0]
@@ -317,6 +320,7 @@ def first_back_track(i, j, b, search_path, a_types):
i = i-s
j = j-t
if i == 0 and j == 0:
return alignment[::-1]
@nb.jit(nopython=True, fastmath=True, cache=True)