Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CjangCjengh committed Oct 18, 2022
1 parent 3cbd522 commit 019af02
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
6 changes: 2 additions & 4 deletions text/cleaners.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,8 @@ def chinese_dialect_cleaners(text):
from text.cantonese import cantonese_to_ipa
from text.english import english_to_lazy_ipa2
from text.ngu_dialect import ngu_dialect_to_ipa
text = re.sub(r'\[(MD|ZH)\](.*?)\[\1\]',
lambda x: chinese_to_ipa2(x.group(2))+' ', text)
text = re.sub(r'\[TW\](.*?)\[TW\]',
lambda x: chinese_to_ipa2(x.group(1), True)+' ', text)
text = re.sub(r'\[ZH\](.*?)\[ZH\]',
lambda x: chinese_to_ipa2(x.group(1))+' ', text)
text = re.sub(r'\[JA\](.*?)\[JA\]',
lambda x: japanese_to_ipa3(x.group(1)).replace('Q', 'ʔ')+' ', text)
text = re.sub(r'\[SH\](.*?)\[SH\]', lambda x: shanghainese_to_ipa(x.group(1)).replace('1', '˥˧').replace('5',
Expand Down
11 changes: 4 additions & 7 deletions text/mandarin.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def number_to_chinese(text):
return text


def chinese_to_bopomofo(text, taiwanese=False):
def chinese_to_bopomofo(text):
text = text.replace('、', ',').replace(';', ',').replace(':', ',')
words = jieba.lcut(text, cut_all=False)
text = ''
Expand All @@ -257,10 +257,7 @@ def chinese_to_bopomofo(text, taiwanese=False):
bopomofos[i] = re.sub(r'([\u3105-\u3129])$', r'\1ˉ', bopomofos[i])
if text != '':
text += ' '
if taiwanese:
text += '#'+'#'.join(bopomofos)
else:
text += ''.join(bopomofos)
text += ''.join(bopomofos)
return text


Expand Down Expand Up @@ -321,9 +318,9 @@ def chinese_to_ipa(text):
return text


def chinese_to_ipa2(text, taiwanese=False):
def chinese_to_ipa2(text):
text = number_to_chinese(text)
text = chinese_to_bopomofo(text, taiwanese)
text = chinese_to_bopomofo(text)
text = latin_to_bopomofo(text)
text = bopomofo_to_ipa2(text)
text = re.sub(r'i([aoe])', r'j\1', text)
Expand Down
5 changes: 3 additions & 2 deletions text/ngu_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
dialects = {'SZ': 'suzhou', 'WX': 'wuxi', 'CZ': 'changzhou', 'HZ': 'hangzhou',
'SX': 'shaoxing', 'NB': 'ningbo', 'JJ': 'jingjiang', 'YX': 'yixing',
'JD': 'jiading', 'ZR': 'zhenru', 'PH': 'pinghu', 'TX': 'tongxiang',
'JS': 'jiashan', 'XS': 'xiashi', 'LP': 'linping', 'XS': 'xiaoshan',
'FY': 'fuyang', 'RA': 'ruao', 'CX': 'cixi', 'SM': 'sanmen', 'TT': 'tiantai'}
'JS': 'jiashan', 'HN': 'xiashi', 'LP': 'linping', 'XS': 'xiaoshan',
'FY': 'fuyang', 'RA': 'ruao', 'CX': 'cixi', 'SM': 'sanmen',
'TT': 'tiantai', 'WZ': 'wenzhou', 'SC': 'suichang', 'YB': 'youbu'}

converters = {}

Expand Down

0 comments on commit 019af02

Please sign in to comment.