Skip to content

Commit

Permalink
fixes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
nishimotz committed Jan 6, 2016
1 parent ec068b4 commit e445635
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
2 changes: 2 additions & 0 deletions jptools/jtalkRunner.py
Expand Up @@ -156,6 +156,8 @@ def main(do_play = False, do_write = True, do_log = False):
Mecab_initialize(__print, JT_DIR, os.path.join(JT_DIR, 'dic'))

msgs = [
"Huawei's",
"Huawei's new Swarovski-bedazzled Jewel watch — CES 2016",
'100.25ドル。ウェルカムトゥー nvda テンキーのinsertキーと、メインのinsertキーの両方が、nvdaキーとして動作します',
'マーク。まーく。',
]
Expand Down
35 changes: 20 additions & 15 deletions source/synthDrivers/jtalk/mecab.py
Expand Up @@ -13,6 +13,7 @@
import re
from text2mecab import text2mecab
from roma2kana import getKanaFromRoma
from _nvdajp_spellchar import convert as convertSpellChar

c_double_p = POINTER(c_double)
c_double_p_p = POINTER(c_double_p)
Expand Down Expand Up @@ -224,33 +225,37 @@ def getMoraCount(s):
RE_FULLSHAPE_ALPHA = re.compile(u'^[A-Za-z]+$')

def _makeFeatureFromLatinWordAndPostfix(org, ar):
_hyoki = ar[0]
_yomi = ar[8] if len(ar) > 8 else convertSpellChar(_hyoki).replace(' ', '')
_pron = ar[9] if len(ar) > 9 else convertSpellChar(_hyoki).replace(' ', '')
hin1 = ar[1]
hin2 = ar[2]
hin3 = ar[3]
postfix = u''
if org == u's':
postfix = u'ズ'
if ar[0].endswith(u'p') or ar[0].endswith(u'ke') or ar[0].endswith(u'rk'):
if _hyoki.endswith(u'p') or _hyoki.endswith(u'ke') or _hyoki.endswith(u'rk'):
postfix = u'ス'
elif org in (u'd', u'ed'):
if ar[0].endswith(u'te') and ar[8].endswith(u'ト'):
if _hyoki.endswith(u'te') and _yomi.endswith(u'ト'):
# update アップデート -> updated アップデーティド
postfix = u'ティド'
ar[8] = ar[8][:-1]
ar[9] = ar[9][:-1]
_yomi = _yomi[:-1]
_pron = _pron[:-1]
else:
postfix = u'ド'
elif org == u'r':
postfix = u'ア'
if ar[0].endswith(u'se'):
if _hyoki.endswith(u'se'):
postfix = u'ザー'
ar[8] = ar[8][:-1]
ar[9] = ar[9][:-1]
hyoki = ar[0] + org
hin1 = ar[1]
hin2 = ar[2]
yomi = ar[8] + postfix
pron = ar[9] + postfix
mora = getMoraCount(ar[10]) + 1
feature = u'{h},{h1},{h2},*,*,*,*,{h},{y},{p},0/{m},C0'.format(
h=hyoki, h1=hin1, h2=hin2, y=yomi, p=pron, m=mora
_yomi = _yomi[:-1]
_pron = _pron[:-1]
hyoki = _hyoki + org
yomi = _yomi + postfix
pron = _pron + postfix
mora = getMoraCount(ar[10]) + 1 if len(ar) > 10 else len(pron)
feature = u'{h},{h1},{h2},{h3},*,*,*,{h},{y},{p},0/{m},C0'.format(
h=hyoki, h1=hin1, h2=hin2, h3=hin3, y=yomi, p=pron, m=mora
)
return feature

Expand Down

0 comments on commit e445635

Please sign in to comment.