開放中文轉換(Pure Python)
Open Chinese convert (OpenCC) in pure Python.
Introduction 簡介
opencc-python 是用純 Python 所寫,使用由 BYVoid(byvoid.kcp@gmail.com) 所開發的 OpenCC 中的字典檔案。
opencc-python 可以支援 Python2.7 及 Python3.x。
opencc-python is made by pure Python with the dictionary files of OpenCC which is developed by BYVoid(byvoid.kcp@gmail.com).
opencc-python can run with Python2.7 and Python3.x.
Installation 安裝
將 opencc 這個目錄複製到你正在開發的專案中即可,或是執行(需要管理者權限):
python setup.py install
套件也可從 PyPI 安裝,使用指令:
pip install opencc-python-reimplemented
Copy the opencc folder to your project, or run (admin required)
python setup.py install
The package can also be installed from PyPI by issuing:
pip install opencc-python-reimplemented
Usage 使用方式
Code
from opencc import OpenCC
cc = OpenCC('s2t') # convert from Simplified Chinese to Traditional Chinese
# can also set conversion by calling set_conversion
# cc.set_conversion('s2tw')
to_convert = '开放中文转换'
converted = cc.convert(to_convert)
Command Line
usage: python -m opencc [-h] [-i <file>] [-o <file>] [-c <conversion>]
[--in-enc <encoding>] [--out-enc <encoding>]
optional arguments:
-h, --help show this help message and exit
-i <file>, --input <file>
Read original text from <file>. (default: None = STDIN)
-o <file>, --output <file>
Write converted text to <file>. (default: None = STDOUT)
-c <conversion>, --config <conversion>
Conversion (default: None)
--in-enc <encoding> Encoding for input (default: UTF-8)
--out-enc <encoding> Encoding for output (default: UTF-8)
example with UTF-8 encoded file:
python -m opencc -c s2t -i my_simplified_input_file.txt -o my_traditional_output_file.txt
See https://docs.python.org/3/library/codecs.html#standard-encodings for list of encodings.
Conversions 轉換
-
hk2s: Traditional Chinese (Hong Kong standard) to Simplified Chinese -
s2hk: Simplified Chinese to Traditional Chinese (Hong Kong standard) -
s2t: Simplified Chinese to Traditional Chinese -
s2tw: Simplified Chinese to Traditional Chinese (Taiwan standard) -
s2twp: Simplified Chinese to Traditional Chinese (Taiwan standard, with phrases) -
t2hk: Traditional Chinese to Traditional Chinese (Hong Kong standard) -
t2s: Traditional Chinese to Simplified Chinese -
t2tw: Traditional Chinese to Traditional Chinese (Taiwan standard) -
tw2s: Traditional Chinese (Taiwan standard) to Simplified Chinese -
tw2sp: Traditional Chinese (Taiwan standard) to Simplified Chinese (with phrases)
Issues 問題
當轉換有兩個以上的字詞可能時,程式只會使用第一個。
When there is more than one conversion available, only the first one is taken.
Metadata
Release files for opencc-python-reimplemented 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| opencc-python-reimplemented-0.1.7.tar.gz | 482.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opencc_python_reimplemented-0.1.7-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 964.4 kB
Release files / opencc-python-reimplemented-0.1.7.tar.gz
| Download URL | opencc-python-reimplemented-0.1.7.tar.gz |
|---|---|
| Size | 482.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f777ea3461a25257a7b876112cfa90bb6acabc6dfb843bf4d11266e43579dee
|
|
BLAKE2b-256 checksum How to use checksums |
8d6dc6f37eed651dd6b752e50f80a93396cdaa42a6acc6ce05ad7452303ea511
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / opencc_python_reimplemented-0.1.7-py2.py3-none-any.whl
| Download URL | opencc_python_reimplemented-0.1.7-py2.py3-none-any.whl |
|---|---|
| Size | 481.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
41b3b92943c7bed291f448e9c7fad4b577c8c2eae30fcfe5a74edf8818493aa6
|
|
BLAKE2b-256 checksum How to use checksums |
306b055b7806f320cc8f2cdf23c5f70221c0dc1683fca9ffaf76dfc2ad4b91b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for opencc-python-reimplemented 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.