Skip to content

Commit e16eea1

Browse files
committed
Fix input for phonetic symbol "ㄍㄟ".
1 parent e325d31 commit e16eea1

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

python/input_methods/braille_chewing/braille_chewing_ime.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,12 @@ def handle_braille_keys(self, keyEvent):
182182
last_bopomofo = self.get_chewing_bopomofo_buffer()
183183
if current_braille == '356': # ['ㄧㄛ', 'ㄟ']
184184
# 上一個注音不是聲母 => ㄧㄛ, 否則 'ㄟ'
185-
#if not last_bopomofo or not bopomofo_is_category(last_bopomofo[-1], "聲母"):
186-
if not last_bopomofo:
187-
bopomofo_seq = 'ㄧㄛ'
188-
else:
185+
# 還需要檢查特例,上一個點字是 13 時,注音尚未確定,此時 last_bopomofo = None
186+
# 但有可能是ㄍ,可以接ㄟ,所以檢查上一個點字是否為 "13"
187+
if (last_bopomofo and bopomofo_is_category(last_bopomofo[-1], "聲母")) or self.last_braille == "13":
189188
bopomofo_seq = 'ㄟ'
189+
else:
190+
bopomofo_seq = 'ㄧㄛ'
190191
elif current_braille == '1': # ['ㄓ', '˙']
191192
# 沒有前一個注音,或前一個不是韻母 => ㄓ
192193
if not last_bopomofo or not bopomofo_is_category(last_bopomofo[-1], "韻母"):
@@ -208,7 +209,7 @@ def handle_braille_keys(self, keyEvent):
208209
last_bopomofo = {'13': 'ㄍ', '15': 'ㄙ', '245': 'ㄘ'}.get(self.last_braille)
209210
bopomofo_seq = last_bopomofo + bopomofo_seq
210211
elif bopomofo_seq in ('ㄧ', 'ㄩ') or (bopomofo_is_category(bopomofo_seq, "疊韻") and bopomofo_seq[0] in ('ㄧ', 'ㄩ')):
211-
# ㄧ,ㄩ疊韻 或 ㄧ、ㄩ直接當韻母
212+
# ㄧ,ㄩ疊韻 或 ㄧ、ㄩ直接當韻母
212213
last_bopomofo = {'13': 'ㄐ', '15': 'ㄒ', '245': 'ㄑ'}.get(self.last_braille)
213214
bopomofo_seq = last_bopomofo + bopomofo_seq
214215
else:
@@ -226,16 +227,16 @@ def handle_braille_keys(self, keyEvent):
226227
def toggleLanguageMode(self):
227228
super().toggleLanguageMode()
228229
if self.chewingContext:
229-
# 播放語音檔,說明目前是中文/英文
230+
# 播放語音檔,說明目前是中文/英文
230231
mode = self.chewingContext.get_ChiEngMode()
231232
snd_file = os.path.join(self.sounds_dir, "chi.wav" if mode == CHINESE_MODE else "eng.wav")
232233
winsound.PlaySound(snd_file, winsound.SND_FILENAME|winsound.SND_ASYNC)
233234

234-
# 切換全形/半形
235+
# 切換全形/半形
235236
def toggleShapeMode(self):
236237
super().toggleShapeMode()
237238
if self.chewingContext:
238-
# 播放語音檔,說明目前是全形/半形
239+
# 播放語音檔,說明目前是全形/半形
239240
mode = self.chewingContext.get_ShapeMode()
240241
snd_file = os.path.join(self.sounds_dir, "full.wav" if mode == FULLSHAPE_MODE else "half.wav")
241242
winsound.PlaySound(snd_file, winsound.SND_FILENAME|winsound.SND_ASYNC)

python/input_methods/braille_chewing/brl_tables.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,18 @@
120120

121121
# 注音符號分類查表
122122
_bopomofo_categories = {
123-
"聲母": set("ㄍㄎㄐㄑㄉㄊㄋㄅㄆㄇㄈㄗㄘㄙㄓㄔㄕㄏㄒㄌㄖ"),
124-
"介音": set("ㄧㄨㄩ"),
125-
"韻母": set("ㄚㄛㄜㄝㄟㄞㄠㄡㄢㄤㄣㄥㄦ"),
126-
"舌尖音": set("ㄓㄔㄕㄖㄗㄘㄙ")
123+
"聲母": set("ㄍㄎㄐㄑㄉㄊㄋㄅㄆㄇㄈㄗㄘㄙㄓㄔㄕㄏㄒㄌㄖ"),
124+
"介音": set("ㄧㄨㄩ"),
125+
"韻母": set("ㄚㄛㄜㄝㄟㄞㄠㄡㄢㄤㄣㄥㄦ"),
126+
"舌尖音": set("ㄓㄔㄕㄖㄗㄘㄙ")
127127
}
128128

129129

130130
# 檢查注音符號是否屬於某分類
131131
def bopomofo_is_category(bopomofo, category):
132-
if category.endswith("疊韻"): # 檢查是否為疊韻 (不完全精確,沒有檢查是否為正確注音)
133-
return len(bopomofo) == 2 and bopomofo_is_category(bopomofo[0], "介音") and bopomofo_is_category(bopomofo[1], "韻母")
134-
return (bopomofo in _bopomofo_categories[category])
132+
if category.endswith("疊韻"): # 檢查是否為疊韻 (不完全精確,沒有檢查是否為正確注音)
133+
return len(bopomofo) == 2 and bopomofo_is_category(bopomofo[0], "介音") and bopomofo_is_category(bopomofo[1], "韻母")
134+
return (bopomofo in _bopomofo_categories[category])
135135

136136

137137
brl_phonic_dic = { # 共計 59 個 不函標點
@@ -215,16 +215,16 @@ def bopomofo_is_category(bopomofo, category):
215215
'245': 'CHECK_NEXT', # ['ㄑ', 'ㄘ'],
216216
# 其他特例
217217
'156': 'CHECK_PREVIOUS', #'ㄦ'
218-
219-
# 標點符號
220-
'23': '<', # ,: shift + ,
221-
'36': '>', # 。: shift + .
218+
219+
# 標點符號
220+
'23': '<', # ,: shift + ,
221+
'36': '>', # 。: shift + .
222222
}
223223

224224
# 注音後再按下 space key 可轉變為標點
225225
brl_space_dic = {
226-
"ㄅ": ")", # ")",
227-
"ㄋ": "?", # "?",
228-
"ㄎ": "!", # "!",
229-
"ㄧㄠ": "(" # "(",
226+
"ㄅ": ")", # ")",
227+
"ㄋ": "?", # "?",
228+
"ㄎ": "!", # "!",
229+
"ㄧㄠ": "(" # "(",
230230
}

0 commit comments

Comments
 (0)