You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def convertVocabulary(string_in, dic, re_dic):
i = 0
while i < len(string_in):
for j in range(len(string_in) - i, 0, -1):
if string_in[i:][:j] in dic:
t = dic[string_in[i:][:j]]
string_in = string_in[:i] + t + string_in[i:][j:]
i += len(t) - 1
break
i += 1
for pattern, repl in re_dic.iteritems():
if pattern.search(string_in):
string_in = pattern.sub(repl, string_in)
return string_in
於 dic_tw.py加入
dic_re_tw = {
u"(^|\W)(餵)(\W|$)":u"\g<1>喂\g<3>"
}
The text was updated successfully, but these errors were encountered:
偶爾有字幕會遇到簡體一字對應到繁體多字的情況,大多數的確可以經由字典檔處理,但少數會遇到問題。
如:
原簡體:-喂 請問在家嗎? (繁體化)
轉換後:-餵 請問在家嗎?
如果可以利用正規表示式,就可以加以修正
修改
我將 convertVocabulary(): 修改為
於 dic_tw.py加入
The text was updated successfully, but these errors were encountered: