cw5 tetragram

This commit is contained in:
Krystian Wasilewski 2023-04-10 17:33:52 +02:00
parent b7e27a1f1d
commit 37a762f54e
3 changed files with 647 additions and 644 deletions

View File

@ -116,10 +116,13 @@ def candidates(left_context, right_context):
cand = sorted(list(cand.items()), key=lambda x: x[1], reverse=True)[:5]
norm = [(x[0], float(x[1]) / sum([y[1] for y in cand])) for x in cand]
for index, elem in enumerate(norm):
unk = None
if 'UNK' in elem:
unk = norm.pop(index)
norm.append(('', unk[1]))
break
if unk is None:
norm[-1] = ('', norm[-1][1])
return ' '.join([f'{x[0]}:{x[1]}' for x in norm])

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff