OSDN Git Service

ti31182 fixed quotes in NABCC
authorTakuya Nishimoto <nishimotz@gmail.com>
Tue, 10 Jun 2014 02:44:05 +0000 (11:44 +0900)
committerTakuya Nishimoto <nishimotz@gmail.com>
Tue, 10 Jun 2014 02:44:05 +0000 (11:44 +0900)
jptools/nabccHarness.py
source/synthDrivers/jtalk/translator2.py

index 04afabd..9c2893f 100644 (file)
@@ -14,46 +14,55 @@ tests = [
        { 'note': '+ 日本語点字とNABCCの併用モード +' },
        {
                'mode':   'NABCC',
+               'text':  'abcdefghijklmnopqrstuvwxyz',
                'input':  'abcdefghijklmnopqrstuvwxyz',
                'output': '⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵',
                },
        {
                'mode':   'NABCC',
-               'input':  'aアbcdefghijklmnopqrstuvwxyzア',
-               'output': '⠁⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵⠁',
+               'text':  'aアbcdefghijklmnopqrstuvwxyzア',
+               'input':  'a アbcdefghijklmnopqrstuvwxyz ア',
+               'output': '⠁ ⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵ ⠁',
                },
        {
                'mode':   'NABCC',
+               'text':  '1234567890',
                'input':  '1234567890',
                'output': '⠂⠆⠒⠲⠢⠖⠶⠦⠔⠴',
                },
        {
                'mode':   'NABCC',
+               'text':  'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                'input':  'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                'output': '⡁⡃⡉⡙⡑⡋⡛⡓⡊⡚⡅⡇⡍⡝⡕⡏⡟⡗⡎⡞⡥⡧⡺⡭⡽⡵',
                },
        {
                'mode':   'NABCC',
+               'text':  ',;:.!"',
                'input':  ',;:.!"',
                'output': '⠠⠰⠱⠨⠮⠐',
                },
        {
                'mode':   'NABCC',
+               'text':  "'()-",
                'input':  "'()-",
                'output': '⠄⠷⠾⠤',
                },
        {
                'mode':   'NABCC',
+               'text':  '_<=>%+~`',
                'input':  '_<=>%+~`',
                'output': '⠸⠣⠿⠜⠩⠬⠘⠈',
                },
        {
                'mode':   'NABCC',
+               'text':  '&$?{[}]',
                'input':  '&$?{[}]',
                'output': '⠯⠫⠹⠪⡪⠻⡻',
                },
        {
                'mode':   'NABCC',
+               'text':  '^@#\\|/*',
                'input':  '^@#\\|/*',
                'output': '⡘⡈⠼⡳⠳⠌⠡',
                },
index 0b58ba6..f217052 100644 (file)
@@ -973,21 +973,22 @@ def japanese_braille_separate(inbuf, logwrite, nabcc=False):
                        else:\r
                                mo.output = '⠦' + mo.nhyouki + '⠴'\r
 \r
-       for mo in li:\r
-               # 情報処理点字でも外国語引用符でもなく output が & を含む場合は前後をあける\r
-               if not mo.output.startswith('⠠⠦') and not mo.output.startswith('⠦'):\r
-                       # &\r
-                       if mo.output == '&':\r
-                               continue\r
-                       # &xx\r
-                       elif mo.output.startswith('&'):\r
-                               mo.output = mo.output.replace('&', '& ')\r
-                       # xx&\r
-                       elif mo.output.endswith('&'):\r
-                               mo.output = mo.output.replace('&', ' &')\r
-                       # xx&xx\r
-                       else:\r
-                               mo.output = mo.output.replace('&', ' & ')\r
+       if not nabcc:\r
+               for mo in li:\r
+                       # 情報処理点字でも外国語引用符でもなく output が & を含む場合は前後をあける\r
+                       if not mo.output.startswith('⠠⠦') and not mo.output.startswith('⠦'):\r
+                               # &\r
+                               if mo.output == '&':\r
+                                       continue\r
+                               # &xx\r
+                               elif mo.output.startswith('&'):\r
+                                       mo.output = mo.output.replace('&', '& ')\r
+                               # xx&\r
+                               elif mo.output.endswith('&'):\r
+                                       mo.output = mo.output.replace('&', ' &')\r
+                                       # xx&xx\r
+                               else:\r
+                                       mo.output = mo.output.replace('&', ' & ')\r
        \r
        # 日付の和語読み処理\r
        li = fix_japanese_date_morphs(li)\r
@@ -999,6 +1000,18 @@ def japanese_braille_separate(inbuf, logwrite, nabcc=False):
                next_mo = li[i+1] if i+1 < len(li) else None\r
                li[i-1].sepflag = should_separate(prev2_mo, prev_mo, li[i], next_mo, nabcc=nabcc)\r
 \r
+       if nabcc:\r
+               for i in xrange(len(li)):\r
+                       mo = li[i]\r
+                       if mo.output == '”':\r
+                               mo.output = '"'\r
+                       elif mo.output == '’':\r
+                               mo.output = "'"\r
+                       elif mo.output == '‘':\r
+                               mo.output = '`'\r
+                               if i > 0:\r
+                                       li[i-1].sepflag = False\r
+\r
        for mo in li:\r
                mo.write(logwrite)\r
        logwrite('')\r