OSDN Git Service

ti31182 work in progress
authorTakuya Nishimoto <nishimotz@gmail.com>
Mon, 9 Jun 2014 01:57:43 +0000 (10:57 +0900)
committerTakuya Nishimoto <nishimotz@gmail.com>
Mon, 9 Jun 2014 01:57:43 +0000 (10:57 +0900)
jptools/jpBrailleRunner.py
source/synthDrivers/jtalk/translator1.py

index 77be5db..bbffd34 100644 (file)
@@ -66,10 +66,11 @@ def pass1():
        with open(outfile, 'w') as f:\r
                count = 0\r
                for t in tests:\r
+                       nabcc = False\r
                        if t.has_key('mode') and t['mode'] == 'NABCC':\r
-                               continue\r
+                               nabcc = True\r
                        if t.has_key('output'):\r
-                               result, inpos1 = translator1.translateWithInPos(t['input'])\r
+                               result, inpos1 = translator1.translateWithInPos(t['input'], nabcc=nabcc)\r
                                if t.has_key('inpos1'):\r
                                        correct_inpos1 = ','.join(['%d' % n for n in t['inpos1'] ])\r
                                else:\r
index 8b2f29c..7cf91c3 100644 (file)
@@ -350,7 +350,19 @@ def is_ara(c):
        # 数字の後につなぎ符が必要\r
        return c in 'アイウエオラリルレロ'\r
 \r
-def translateWithInPos(text):\r
+def make_nabcc_dic():\r
+       dic = {}\r
+       for c in alpha_dic:\r
+               dic[c] = alpha_dic[c]\r
+       keys = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ,;:.!"\'()-_<=>%+~`&$?{[}]^@#\\|/*'\r
+       vals = '⠴⠂⠆⠒⠲⠢⠖⠶⠦⠔⡁⡃⡉⡙⡑⡋⡛⡓⡊⡚⡅⡇⡍⡝⡕⡏⡟⡗⡎⡞⡥⡧⡺⡭⡽⡵⠠⠰⠱⠨⠮⠐⠄⠷⠾⠤⠸⠣⠿⠜⠩⠬⠘⠈⠯⠫⠹⠪⡪⠻⡻⡘⡈⠼⡳⠳⠌⠡'\r
+       for pos in xrange(len(keys)):\r
+               dic[keys[pos]] = vals[pos]\r
+       return dic\r
+\r
+nabcc_dic = make_nabcc_dic()\r
+\r
+def translateWithInPos(text, nabcc=False):\r
        retval = ''\r
        pos = 0\r
        latin = False # 外字符モード\r
@@ -368,6 +380,11 @@ def translateWithInPos(text):
                        inPos.append(pos)\r
                        capital = latin = num = False\r
                        pos += 1\r
+               #nabcc\r
+               elif nabcc and (text[pos] in nabcc_dic):\r
+                       retval += nabcc_dic[text[pos]]\r
+                       inPos.append(pos)\r
+                       pos += 1\r
                #Numeric\r
                elif text[pos] in num_dic:\r
                        latin = False\r