Skip to content

Commit

Permalink
Add experimental cnt support
Browse files Browse the repository at this point in the history
  • Loading branch information
ayaka14732 committed Apr 26, 2022
1 parent 647d6e7 commit 183463d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ convert('拥有 116 年历史') # Wrong: 擁有 116 年曆史
- `cn`: Simplified Chinese (Mainland China)
- `hk`: Traditional Chinese (Hong Kong)
- `tw`: Traditional Chinese (Taiwan)
- `cnt`: Traditional Chinese (Mainland China)
- `jp`: Japanese Shinjitai

The support of `cnt` is currently experimental.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='starcc',
version='0.0.3',
version='0.0.4',
description='Python implementation of StarCC',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
2 changes: 2 additions & 0 deletions src/StarCC/Dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ class Dicts:
TW2ST = ('TWVariantsRev', 'TWVariantsRevPhrases')
TWP2ST = ('TWVariantsRev', 'TWVariantsRevPhrases', 'TWPhrasesRev')
HK2ST = ('HKVariantsRev', 'HKVariantsRevPhrases')
CNT2ST = ('CNTradVariantsRev', 'CNTradRevPhrases'),
JP2ST = ('JPVariantsRev', 'JPShinjitaiCharacters', 'JPShinjitaiPhrases')

ST2CN = ('TSCharacters', 'TSPhrases')
ST2HK = ('HKVariants',)
ST2TW = ('TWVariants',)
ST2TWP = ('TWVariants', 'TWPhrasesIT', 'TWPhrasesName', 'TWPhrasesOther')
ST2CNT = ('CNTradVariants', 'CNTradPhrases')
ST2JP = ('JPVariants',)
6 changes: 4 additions & 2 deletions src/StarCC/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def __init__(self, src: str='cn', dst: str='hk', with_phrase: bool=False, use_se
from Simplified to Traditional, this option has no effect.
'''

if src not in ('st', 'cn', 'hk', 'tw', 'jp'):
if src not in ('st', 'cn', 'hk', 'tw', 'cnt', 'jp'):
raise ValueError(f'Invalid src value: {src}')
if dst not in ('st', 'cn', 'hk', 'tw', 'jp'):
if dst not in ('st', 'cn', 'hk', 'tw', 'cnt', 'jp'):
raise ValueError(f'Invalid dst value: {dst}')
assert src != dst

Expand All @@ -112,6 +112,7 @@ def __init__(self, src: str='cn', dst: str='hk', with_phrase: bool=False, use_se
'cn': Dicts.CN2ST,
'hk': Dicts.HK2ST,
'tw': Dicts.TW2ST,
'cnt': Dicts.CNT2ST,
'jp': Dicts.JP2ST,
}[src])
else: # with_phrase
Expand All @@ -134,6 +135,7 @@ def __init__(self, src: str='cn', dst: str='hk', with_phrase: bool=False, use_se
'cn': Dicts.ST2CN,
'hk': Dicts.ST2HK,
'tw': Dicts.ST2TW,
'cnt': Dicts.ST2CNT,
'jp': Dicts.ST2JP,
}[dst])
else: # with_phrase
Expand Down

0 comments on commit 183463d

Please sign in to comment.