mirror of
https://github.com/Helsinki-NLP/OPUS-MT-train.git
synced 2024-08-17 00:00:33 +03:00
Merge branch 'master' of github.com:Helsinki-NLP/OPUS-MT-train
This commit is contained in:
commit
dbcdab4d6b
4
NOTES.md
4
NOTES.md
@ -1,4 +1,8 @@
|
||||
|
||||
# Integration
|
||||
|
||||
https://github.com/UKPLab/EasyNMT
|
||||
|
||||
|
||||
# more efficient parallelisation
|
||||
|
||||
|
30
scripts/fix_vocab.py
Executable file
30
scripts/fix_vocab.py
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
#-*-python-*-
|
||||
|
||||
import yaml
|
||||
import sys
|
||||
from shutil import copyfile
|
||||
|
||||
|
||||
filename = sys.argv[1]
|
||||
|
||||
try:
|
||||
input = open(filename, 'r')
|
||||
yaml.load(input)
|
||||
except:
|
||||
print('YAML file is broken - try to fix it!')
|
||||
print(f'copy {filename} to {filename}.bak')
|
||||
copyfile(filename, f'{filename}.bak')
|
||||
|
||||
vocab={}
|
||||
# for line in sys.stdin:
|
||||
with open(filename) as fh:
|
||||
for line in fh:
|
||||
parts = line.rstrip().split(': ')
|
||||
parts[0] = parts[0][1:-1]
|
||||
vocab[parts[0]] = int(parts[1])
|
||||
|
||||
|
||||
print(f'write a new version of {filename}')
|
||||
output = open(filename, 'w')
|
||||
yaml.dump(vocab, output, allow_unicode=True)
|
Loading…
Reference in New Issue
Block a user