修訂 | 10c88870e428fb04a60bbf4e8161201ee53b335b (tree) |
---|---|
時間 | 2014-05-03 19:28:04 |
作者 | Takuya Nishimoto <nishimotz@gmai...> |
Commiter | Takuya Nishimoto |
fixed issue ti33675
@@ -56,10 +56,11 @@ def get_reading(msg): | ||
56 | 56 | return reading |
57 | 57 | |
58 | 58 | def runTasks(enableUserDic=False): |
59 | - print jt_dir, dic, user_dics_org, user_dics | |
60 | 59 | if enableUserDic: |
60 | + print jt_dir, dic, user_dics | |
61 | 61 | Mecab_initialize(__print, jt_dir, dic, user_dics) |
62 | 62 | else: |
63 | + print jt_dir, dic | |
63 | 64 | Mecab_initialize(__print, jt_dir, dic) |
64 | 65 | count = 0 |
65 | 66 | for i in tasks: |
@@ -19,7 +19,9 @@ class JpBrailleTests(unittest.TestCase): | ||
19 | 19 | class MecabTests(unittest.TestCase): |
20 | 20 | |
21 | 21 | def test_all(self): |
22 | - count = mecabRunner.runTasks() | |
22 | + count = mecabRunner.runTasks(enableUserDic=False) | |
23 | + self.assertEqual(count, 0) | |
24 | + count = mecabRunner.runTasks(enableUserDic=True) | |
23 | 25 | self.assertEqual(count, 0) |
24 | 26 | |
25 | 27 | class JtalkPrepareTests(unittest.TestCase): |
@@ -129,12 +129,13 @@ def Mecab_initialize(logwrite_ = None, libmecab_dir = None, dic = None, user_dic | ||
129 | 129 | raise RuntimeError('utf-8 dictionary for mecab required.') |
130 | 130 | except: |
131 | 131 | pass |
132 | - argc, args = 3, (c_char_p * 3)('mecab', '-d', dic.encode('utf-8')) | |
132 | + mecabrc = os.path.join(libmecab_dir, 'mecabrc') | |
133 | + argc, args = 5, (c_char_p * 5)('mecab', '-d', dic.encode('utf-8'), '-r', mecabrc.encode('utf-8')) | |
133 | 134 | if user_dics: |
134 | 135 | # ignore item which contains comma |
135 | 136 | ud = ','.join([s for s in user_dics if not ',' in s]) |
136 | 137 | if logwrite_: logwrite_(u'user_dics: %s' % ud) |
137 | - argc, args = 5, (c_char_p * 5)('mecab', '-d', dic.encode('utf-8'), '-u', ud.encode('utf-8')) | |
138 | + argc, args = 7, (c_char_p * 7)('mecab', '-d', dic.encode('utf-8'), '-r', mecabrc.encode('utf-8'), '-u', ud.encode('utf-8')) | |
138 | 139 | mecab = libmc.mecab_new(argc, args) |
139 | 140 | if logwrite_: |
140 | 141 | if not mecab: logwrite_('mecab_new failed.') |