-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake_mod.py
More file actions
55 lines (42 loc) · 1.52 KB
/
make_mod.py
File metadata and controls
55 lines (42 loc) · 1.52 KB
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
#! /usr/bin/env python
# coding:utf-8
import config
def make_model_mod(
phrase,
bigram,
):
'''
特別な語用の mod ファイルを生成する。
phrase で変換したい語を指定する。
bigram で組み合わせてはいけない語を指定する。
'''
phrase_fd = open(phrase, "w")
bigram_fd = open(bigram, "w")
# phrase
for word in config.XTU_REPLACE:
print("{0},っ\t0.9".format(word), file=phrase_fd)
print("{0},{0}\t0.1".format(word), file=phrase_fd)
for word in config.XTU_ADD:
print("{0},っ{0}\t0.9".format(word), file=phrase_fd)
print("{0},{0}\t0.1".format(word), file=phrase_fd)
print("make mod.model file: {}".format(phrase))
# bigram
print("っ っ\t1e-10", file=bigram_fd)
print("っ ッ\t1e-10", file=bigram_fd)
print("っ *\t1e-3", file=bigram_fd)
print("ッ っ\t1e-10", file=bigram_fd)
print("ッ ッ\t1e-10", file=bigram_fd)
print("ッ *\t1e-3", file=bigram_fd)
for word in config.XTU_REPLACE:
print("{0} っ\t1e-10".format(word), file=bigram_fd)
print("{0} *\t1e-3".format(word), file=bigram_fd)
# print("っ {0}\t1e-10".format(word), file=bigram_fd)
for word in config.XTU_ADD:
print("{0} っ\t1e-10".format(word), file=bigram_fd)
print("{0} *\t1e-3".format(word), file=bigram_fd)
print("make mod.model file: {}".format(bigram))
if __name__ == '__main__':
make_model_mod(
config.PHRASE_MODEL_MOD,
config.BIGRAM_MODEL_MOD
)