Skip to main content

Openccpy

  ___   _____      __    ___     ___    ___   _____   __  __
 / __`\/\ '__`\  /'__`\/' _ `\  /'___\ /'___\/\ '__`\/\ \/\ \
/\ \L\ \ \ \L\ \/\  __//\ \/\ \/\ \__//\ \__/\ \ \L\ \ \ \_\ \
\ \____/\ \ ,__/\ \____\ \_\ \_\ \____\ \____\\ \ ,__/\/`____ \
 \/___/  \ \ \/  \/____/\/_/\/_/\/____/\/____/ \ \ \/  `/___/> \
          \ \_\                                 \ \_\     /\___/
           \/_/                                  \/_/     \/__/

PYPI Build Status Coverage Status

Open Chinese Convert is an opensource project for conversion between Traditional Chinese and Simplified Chinese for python.

(python 中文繁简体转换工具)

特性

  • 支持中文繁简体转换(v0.0.2)

Quick Start

install

pip install openccpy

使用案例

# coding=utf-8
from openccpy.opencc import *

class TestOpencc(object):
    """
    核心转换测试类
    """

    def test_to_simple(self):
        """
        测试转换为简体
        """
        assert "丝" == Opencc.to_simple("絲")
        assert "一目了然" == Opencc.to_simple("一目瞭然")

    def test_to_traditional(self):
        """
        测试转化为繁体
        """
        assert "絲" == Opencc.to_traditional("丝")
        assert "一目瞭然" == Opencc.to_traditional("一目了然")

方法简介

转为简体

def to_simple(traditional):
     """
     繁体转化为简体
     1. 如果字符为空,直接返回
     2. 字符长度为1,返回对应简体字符
     3. 对应长度大于1,返回对应简体词组
     :param traditional: 繁体单词/单个词组
     :return: 对应的简体信息
     """

转为繁体

def to_traditional(simple):

    """
    简体转化为繁体
    1. 如果字符为空,直接返回
    2. 字符长度为1,返回对应繁体字符
    3. 对应长度大于1,返回对应繁体词组
    :param simple: 简体单词/单个词组
    :return: 对应的繁体信息
    """

相关框架

中文繁简体转换-java 版本

下期计划

  1. 添加分词功能

Release files for openccpy 0.0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openccpy 0.0.4.3
File Size Uploaded
openccpy-0.0.4.3.tar.gz 459.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openccpy 0.0.4.3
File Interpreter ABI Platform
openccpy-0.0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 918.6 kB

Release files / openccpy-0.0.4.3.tar.gz

Download URL openccpy-0.0.4.3.tar.gz
Size 459.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0ae4d7c31adb2630944437b324002bb8b0f4009891c3ff060d2005ed41172741
BLAKE2b-256 checksum
How to use checksums
e6b9d7e7bd7d5c9b12e55e6489082c5f6908d603933b106cb80df2e805e9acd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

Release files / openccpy-0.0.4.3-py3-none-any.whl

Download URL openccpy-0.0.4.3-py3-none-any.whl
Size 459.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd13c7c4e4b0dc08225feb201abdd14b1fc919fdafa29ad30de5ae4bd297f0dd
BLAKE2b-256 checksum
How to use checksums
abe87e3071828731ebbfdda0a03c179ae43a31131f0c7e4203b75d5230396685
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.0.4.3 This release

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page