-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_core.py
66 lines (55 loc) · 1.55 KB
/
client_core.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import socket
Operation = {
'MT': '0',
'GEC': '1',
'DISCONNECT': '2'
}
Status = {
'SUCCESS': 0,
'FAILED': 1
}
LANG_STOI = {
'en': '0',
'de': '1',
'vi': '2'
}
LANG_ITOS = {
i:s for s,i in LANG_STOI.items()
}
LANG_LABEL_SIZE = len(list(LANG_STOI.values())[0])
# size of encoded language value e.g '0' has size 1
"""
This dictionary shows which languages that server supports in translation.
Add a new item 'lang_label': 'lang_fullname' into this dictionary if a new language is supported.
"""
SUPPORTED_LANGS = {
'en': 'English',
'de': 'German',
'vi': 'Vietnamese'
}
"""
This tuple shows which (source language, target language) pairs that server supports in translation.
Add a new ('source_lang', 'target_lang') into this tuple if a new pair is supported.
"""
SUPPORTED_TRANS = (
('en', 'de'),
('en', 'vi')
)
BUFFER_SIZE = 4089
DELIMITER = '.'
INPUT_PATH = '/input/'
OUTPUT_PATH = '/output/'
EN_DE_TRANSLATION_MODEL_PATH = '/model/translation_model_ende_release.pt'
EN_VI_TRANSLATION_MODEL_PATH = '/model/translation_model_envi_release.pt'
GEC_MODEL_PATH = '/model/gec_model.pt'
EN_VI_SUBWORD_MODEL = '/model/en_vi.source.model'
EN_VI_DESUBWORD_MODEL = '/model/en_vi.target.model'
EN_DE_SUBWORD_MODEL = '/model/en_de.source.model'
EN_DE_DESUBWORD_MODEL = '/model/en_de.target.model'
LEN_PAD = 10
SIGNAL_PAD = 2
TRANS_PAD = 5
HEADER_BUFFER = LEN_PAD + SIGNAL_PAD + TRANS_PAD
PORT = 5555
SERVER_IP = socket.gethostbyname(socket.gethostname())
FORMAT = 'utf-8'