broccoli0510 Claude Opus 5.5 commited on
Commit
0178299
·
1 Parent(s): 42b4bc7

Fix OpenCC mis-converting 了 to 瞭

Browse files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -22,7 +22,11 @@ except ImportError:
22
  try:
23
  from opencc import OpenCC
24
 
25
- _to_tw = OpenCC("s2twp").convert
 
 
 
 
26
  except Exception:
27
  def _to_tw(text):
28
  return text
 
22
  try:
23
  from opencc import OpenCC
24
 
25
+ _cc = OpenCC("s2twp")
26
+
27
+ def _to_tw(text):
28
+ # OpenCC 常把「了」誤轉成「瞭」(例如「宣告瞭」),轉回「了」(「了解」在台灣也是標準寫法)
29
+ return _cc.convert(text).replace("瞭", "了")
30
  except Exception:
31
  def _to_tw(text):
32
  return text