Skip to content

Commit d3fc2d2

Browse files
logo-kuoPCMan
authored andcommitted
fix some bug about 156 and 1 rule
1 parent e16eea1 commit d3fc2d2

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

python/input_methods/braille_chewing/braille_chewing_ime.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
class BrailleChewingTextService(ChewingTextService):
2929

30-
# 鍵盤按鍵轉成點字 1 - 6
30+
# 鍵盤按鍵轉成點字 1 - 8
3131
# A-Z 的 Windows virtual key codes = 大寫的 ASCII code
3232
braille_keys = [
3333
ord('F'), # 1
@@ -187,18 +187,20 @@ def handle_braille_keys(self, keyEvent):
187187
if (last_bopomofo and bopomofo_is_category(last_bopomofo[-1], "聲母")) or self.last_braille == "13":
188188
bopomofo_seq = 'ㄟ'
189189
else:
190+
# 實際上也有可能是要打 ㄟ 接注聲 目前還沒有處理這個部分
190191
bopomofo_seq = 'ㄧㄛ'
191192
elif current_braille == '1': # ['ㄓ', '˙']
192-
# 沒有前一個注音,或前一個不是韻母 => ㄓ
193-
if not last_bopomofo or not bopomofo_is_category(last_bopomofo[-1], "韻母"):
194-
bopomofo_seq = 'ㄓ'
195-
else:
193+
# 前一個注音是韻母,或前一個是舌尖音加 156 點 => ˙
194+
if (last_bopomofo and bopomofo_is_category(last_bopomofo[-1], "韻母")) or (last_bopomofo and bopomofo_is_category(last_bopomofo[-1], "舌尖音")):
196195
bopomofo_seq = '˙'
196+
else:
197+
bopomofo_seq = 'ㄓ'
197198
elif current_braille == '156': # 'ㄦ'
198199
# 如果 ㄦ 前面是舌尖音則呼略 ㄦ
199-
if last_bopomofo and bopomofo_is_category(last_bopomofo[-1], "舌尖音"):
200+
if last_bopomofo and bopomofo_is_category(last_bopomofo[-1], "舌尖音"):
200201
bopomofo_seq = last_bopomofo
201202
else:
203+
# 此時若聲母為 ㄘ 或 ㄙ 先暫時讓 156 變成 ㄦ
202204
bopomofo_seq = 'ㄦ'
203205
else:
204206
bopomofo_seq = None
@@ -207,7 +209,13 @@ def handle_braille_keys(self, keyEvent):
207209
if bopomofo_is_category(bopomofo_seq, "韻母") or (bopomofo_is_category(bopomofo_seq, "疊韻") and bopomofo_seq[0] == 'ㄨ') or bopomofo_seq == 'ㄨ':
208210
# 韻母 或 ㄨ疊韻 或ㄨ直接當韻母
209211
last_bopomofo = {'13': 'ㄍ', '15': 'ㄙ', '245': 'ㄘ'}.get(self.last_braille)
210-
bopomofo_seq = last_bopomofo + bopomofo_seq
212+
# 因為 ㄦ 也是韻母 所以在這邊還必須處理 ㄘ 或 ㄙ + 156 接注聲的狀況
213+
if current_braille == "156":
214+
# 需把 ㄦ 去除 實際上沒有 ㄍㄦ 可以不用手動排除
215+
bopomofo_seq = last_bopomofo
216+
else:
217+
# 一般情況需要把聲母跟韻母或疊韻全部加起來
218+
bopomofo_seq = last_bopomofo + bopomofo_seq
211219
elif bopomofo_seq in ('ㄧ', 'ㄩ') or (bopomofo_is_category(bopomofo_seq, "疊韻") and bopomofo_seq[0] in ('ㄧ', 'ㄩ')):
212220
# ㄧ,ㄩ疊韻 或 ㄧ、ㄩ直接當韻母
213221
last_bopomofo = {'13': 'ㄐ', '15': 'ㄒ', '245': 'ㄑ'}.get(self.last_braille)

0 commit comments

Comments
 (0)