Skip to main content

Python implementation of StarCC

Project description

StarCC-Py

简繁转换 簡繁轉換 Python implementation of StarCC, the next generation of Simplified-Traditional Chinese conversion framework

Discussion - on Telegram

安裝 Installation

pip install starcc

用法 Usage

簡轉繁 Simplified to Traditional

不轉換用詞 Without phrase conversion:

from StarCC import PresetConversion
convert = PresetConversion(src='cn', dst='hk', with_phrase=False)  # change to `dst='tw'` for Taiwan mode
print(convert('阴天,山容便黯澹无聊,半隐入米家的水墨里去。'))
# 陰天,山容便黯澹無聊,半隱入米家的水墨裏去。

轉換用詞 With phrase conversion:

from StarCC import PresetConversion
convert = PresetConversion(src='cn', dst='tw', with_phrase=True)
print(convert('KB 大桥也被视为帕劳人的后花园。'))
# KB 大橋也被視為帛琉人的後花園。

繁轉簡 Traditional to Simplified

不轉換用詞 Without phrase conversion:

from StarCC import PresetConversion
convert = PresetConversion(src='hk', dst='cn', with_phrase=False)  # change to `dst='tw'` for Taiwan mode
print(convert('盆地並不會永久被水覆蓋,而是反覆蒸發循環。'))
# 盆地并不会永久被水覆盖,而是反复蒸发循环。

轉換用詞 With phrase conversion:

from StarCC import PresetConversion
convert = PresetConversion(src='tw', dst='cn', with_phrase=True)
print(convert('在搜尋欄位使用萬用字元。'))
# 在搜索字段使用通配符。

高級用法 Advanced Usage

在簡轉繁時使用外部分詞 Use external segmentation tools when converting from Simplified to Traditional

此功能已預設開啓 This function is enabled by default

from StarCC import PresetConversion
convert = PresetConversion(src='cn', dst='hk', with_phrase=False, use_seg=True)
convert('拥有 116 年历史')  # Correct: 擁有 116 年歷史
convert = PresetConversion(src='cn', dst='hk', with_phrase=False, use_seg=False)
convert('拥有 116 年历史')  # Wrong: 擁有 116 年曆史

轉換模式一覽 Supported conversion modes

  • 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starcc-0.0.4.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

starcc-0.0.4-py3-none-any.whl (483.8 kB view details)

Uploaded Python 3

File details

Details for the file starcc-0.0.4.tar.gz.

File metadata

  • Download URL: starcc-0.0.4.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for starcc-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b1ac4b46b7d266b4cdd3e46420887e973549096cc836c1e9969e16dd131c8d3b
MD5 f1f69001673f4bb1855b9ae0085a119f
BLAKE2b-256 daf8fb489ae902fe9c70d445ae74081f2ee7d94fbc4dfd62d64545daf3c1ebfd

See more details on using hashes here.

Provenance

File details

Details for the file starcc-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: starcc-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 483.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for starcc-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2cc6794defce4da744753479a175c0c29151cc06d3cb9a768974516abce2e475
MD5 94f44f2ba0315a38f04ffcb800b1b634
BLAKE2b-256 1e775906859d3bb628a4f736d157fa87ca5b0a96f3468de12d10dac49956742a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page