You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.
def _adjust(prosody_txt):
'''Make sure that segment word is smaller than prosody word'''
prosody_words = re.split('#\d', prosody_txt)
rhythms = re.findall('#\d', prosody_txt)
txt = ''.join(prosody_words)
words = []
poses = []
# for txt in prosody_words:
for word, pos in posseg.cut(txt):
words.append(word)
poses.append(pos[0])
index = 0
insert_time = 0
length = len(prosody_words[index])
i = 0
while i < len(words):
done = False
while not done:
if (len(words[i]) > length):
#print(words[i], prosody_words[index])
length += len(prosody_words[index + 1])
rhythms[index+ insert_time] = '' #这一行之前是rhythms[index] = ''
index += 1
elif (len(words[i]) < length):
# print(' less than ', words[i], prosody_words[index])
rhythms.insert(index + insert_time, '#0')
# rhythms.insert(index, '#0')
insert_time += 1
length -= len(words[i])
i += 1
else:
# print('equal :', words[i])
# print(rhythms)
done = True
index += 1
else:
if (index < len(prosody_words)):
length = len(prosody_words[index])
i += 1
if rhythms[-1] != '#4':
rhythms.append('#4')
rhythms = [x for x in rhythms if x != '']
# print(rhythms)
return (words, poses, rhythms)
The text was updated successfully, but these errors were encountered: