Skip to main content

Conversion between Traditional and Simplified Chinese

Project description

Open Chinese Convert 開放中文轉換

CMake Bazel MSVC Node.js CI Python CI AppVeyor

Introduction 介紹

OpenCC

Open Chinese Convert (OpenCC, 開放中文轉換) is an opensource project for conversions between Traditional Chinese, Simplified Chinese and Japanese Kanji (Shinjitai). It supports character-level and phrase-level conversion, character variant conversion and regional idioms among Mainland China, Taiwan and Hong Kong. This is not translation tool between Mandarin and Cantonese, etc.

中文簡繁轉換開源項目,支持詞彙級別的轉換、異體字轉換和地區習慣用詞轉換(中國大陸、臺灣、香港、日本新字體)。不提供普通話與粵語的轉換。

Discussion (Telegram): https://t.me/open_chinese_convert

Features 特點

  • 嚴格區分「一簡對多繁」和「一簡對多異」。
  • 完全兼容異體字,可以實現動態替換。
  • 嚴格審校一簡對多繁詞條,原則爲「能分則不合」。
  • 支持中國大陸、臺灣、香港異體字和地區習慣用詞轉換,如「裏」「裡」、「鼠標」「滑鼠」。
  • 詞庫和函數庫完全分離,可以自由修改、導入、擴展。

Installation 安裝

Package Managers 包管理器

Prebuilt 預編譯

Usage 使用

Online demo 線上轉換展示

Warning: This is NOT an API. You will be banned if you make calls programmatically.

https://opencc.byvoid.com/

Node.js

npm npm install opencc

JavaScript

const OpenCC = require('opencc');
const converter = new OpenCC('s2t.json');
converter.convertPromise("汉字").then(converted => {
  console.log(converted);  // 漢字
});

TypeScript

import { OpenCC } from 'opencc';
async function main() {
  const converter: OpenCC = new OpenCC('s2t.json');
  const result: string = await converter.convertPromise('汉字');
  console.log(result);
}

See demo.js and ts-demo.ts.

Python

pip install opencc (Windows, Linux, Mac)

import opencc
converter = opencc.OpenCC('s2t.json')
converter.convert('汉字')  # 漢字

C++

#include "opencc.h"

int main() {
  const opencc::SimpleConverter converter("s2t.json");
  converter.Convert("汉字");  // 漢字
  return 0;
}

Full example with Bazel

C

#include "opencc.h"

int main() {
  opencc_t opencc = opencc_open("s2t.json");
  const char* input = "汉字";
  char* converted = opencc_convert_utf8(opencc, input, strlen(input));  // 漢字
  opencc_convert_utf8_free(converted);
  opencc_close(opencc);
  return 0;
}

Document 文檔: https://byvoid.github.io/OpenCC/

Command Line

  • opencc --help
  • opencc_dict --help
  • opencc_phrase_extract --help

Others (Unofficial)

Configurations 配置文件

預設配置文件

  • s2t.json Simplified Chinese to Traditional Chinese 簡體到繁體
  • t2s.json Traditional Chinese to Simplified Chinese 繁體到簡體
  • s2tw.json Simplified Chinese to Traditional Chinese (Taiwan Standard) 簡體到臺灣正體
  • tw2s.json Traditional Chinese (Taiwan Standard) to Simplified Chinese 臺灣正體到簡體
  • s2hk.json Simplified Chinese to Traditional Chinese (Hong Kong variant) 簡體到香港繁體
  • hk2s.json Traditional Chinese (Hong Kong variant) to Simplified Chinese 香港繁體到簡體
  • s2twp.json Simplified Chinese to Traditional Chinese (Taiwan Standard) with Taiwanese idiom 簡體到繁體(臺灣正體標準)並轉換爲臺灣常用詞彙
  • tw2sp.json Traditional Chinese (Taiwan Standard) to Simplified Chinese with Mainland Chinese idiom 繁體(臺灣正體標準)到簡體並轉換爲中國大陸常用詞彙
  • t2tw.json Traditional Chinese (OpenCC Standard) to Taiwan Standard 繁體(OpenCC 標準)到臺灣正體
  • hk2t.json Traditional Chinese (Hong Kong variant) to Traditional Chinese 香港繁體到繁體(OpenCC 標準)
  • t2hk.json Traditional Chinese (OpenCC Standard) to Hong Kong variant 繁體(OpenCC 標準)到香港繁體
  • t2jp.json Traditional Chinese Characters (Kyūjitai) to New Japanese Kanji (Shinjitai) 繁體(OpenCC 標準,舊字體)到日文新字體
  • jp2t.json New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai) 日文新字體到繁體(OpenCC 標準,舊字體)
  • tw2t.json Traditional Chinese (Taiwan standard) to Traditional Chinese 臺灣正體到繁體(OpenCC 標準)

Build 編譯

Build with CMake

Linux & Mac OS X

g++ 4.6+ or clang 3.2+ is required.

make

Windows Visual Studio:

build.cmd

Build with Bazel

bazel build //:opencc
bazel test --test_output=all //src/... //data/... //test/...

Test 測試

Linux & Mac OS X

make test

Windows Visual Studio:

test.cmd

Benchmark 基準測試

make benchmark

Example results (from Github CI):

1: ------------------------------------------------------------------
1: Benchmark                        Time             CPU   Iterations
1: ------------------------------------------------------------------
1: BM_Initialization/hk2s        1.56 ms         1.56 ms          442
1: BM_Initialization/hk2t       0.144 ms        0.144 ms         4878
1: BM_Initialization/jp2t       0.260 ms        0.260 ms         2604
1: BM_Initialization/s2hk        23.8 ms         23.8 ms           29
1: BM_Initialization/s2t         25.6 ms         25.6 ms           28
1: BM_Initialization/s2tw        24.0 ms         23.9 ms           30
1: BM_Initialization/s2twp       24.6 ms         24.6 ms           28
1: BM_Initialization/t2hk       0.052 ms        0.052 ms        12897
1: BM_Initialization/t2jp       0.141 ms        0.141 ms         5012
1: BM_Initialization/t2s         1.30 ms         1.30 ms          540
1: BM_Initialization/tw2s        1.39 ms         1.39 ms          529
1: BM_Initialization/tw2sp       1.69 ms         1.69 ms          426
1: BM_Initialization/tw2t       0.089 ms        0.089 ms         7707
1: BM_Convert2M                   582 ms          582 ms            1
1: BM_Convert/100                1.07 ms         1.07 ms          636
1: BM_Convert/1000               11.0 ms         11.0 ms           67
1: BM_Convert/10000               113 ms          113 ms            6
1: BM_Convert/100000             1176 ms         1176 ms            1

Projects using OpenCC 使用 OpenCC 的項目

Please update if your project is using OpenCC.

License 許可協議

Apache License 2.0

Third Party Library 第三方庫

All these libraries are statically linked by default.

Change History 版本歷史

Links 相關鏈接

Contributors 貢獻者

Please feel free to update this list if you have contributed OpenCC.

Download files

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

Source Distribution

opencc-1.1.9.tar.gz (3.4 MB view details)

Uploaded Source

Built Distributions

OpenCC-1.1.9-cp312-cp312-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.12 Windows x86-64

OpenCC-1.1.9-cp312-cp312-manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.12

OpenCC-1.1.9-cp312-cp312-macosx_10_9_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

OpenCC-1.1.9-cp311-cp311-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.11 Windows x86-64

OpenCC-1.1.9-cp311-cp311-manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.11

OpenCC-1.1.9-cp311-cp311-macosx_10_9_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

OpenCC-1.1.9-cp310-cp310-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.10 Windows x86-64

OpenCC-1.1.9-cp310-cp310-manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10

OpenCC-1.1.9-cp310-cp310-macosx_10_9_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

OpenCC-1.1.9-cp39-cp39-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.9 Windows x86-64

OpenCC-1.1.9-cp39-cp39-manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.9

OpenCC-1.1.9-cp39-cp39-macosx_10_9_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

OpenCC-1.1.9-cp38-cp38-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.8 Windows x86-64

OpenCC-1.1.9-cp38-cp38-manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.8

OpenCC-1.1.9-cp38-cp38-macosx_10_9_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

Details for the file opencc-1.1.9.tar.gz.

File metadata

  • Download URL: opencc-1.1.9.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.19

File hashes

Hashes for opencc-1.1.9.tar.gz
Algorithm Hash digest
SHA256 8ad72283732951303390fae33a1ceda98ac9b03368a8f2912edc934d74077e4a
MD5 6f445ebbd152b7f9d11d51922d157735
BLAKE2b-256 e6a20e86df1284143c389a3a6e33b159394da34b500a62b2b9c918949a2e6438

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: OpenCC-1.1.9-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for OpenCC-1.1.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 64f8d22c8505b65e8ee2d6e73241cbc92785d38b3c93885b423d7c4fcd31c679
MD5 1c824c9a01b24c5fb625098e858f9617
BLAKE2b-256 2c67fb4fb43c1502fd9f14646211d9643ef67e8123455e176af6668265d2f875

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.9-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1c5d1489bdaf9dc2865f0ea30eb565093253e73c1868d9c19554c8a044b545d4
MD5 24892edc62df89650fc85ec7f8d9b0af
BLAKE2b-256 23f0ddd3522a142ebb66b30c7d30509de940979c2fb30a9edbf417fdfc37278d

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.9-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 48bc3e37942b91a9cf51f525631792f79378e5332bdba9e10c05f6e7fe9036ca
MD5 c4a71f80ff58345c9b4feb368921e755
BLAKE2b-256 8c58d1f270e9d329d4f4f7c1963f9700aa9c9d6f0c5042c641005da6369b4c8e

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: OpenCC-1.1.9-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for OpenCC-1.1.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9f6a1413ca2ff490e65a55822e4cae8c3f104bfab46355288de4893a14470fbb
MD5 ccaa80959c62a4844e269f7af84e4426
BLAKE2b-256 b151b77472e225a2055cb21ab308cabb957e4ec83d2bf427267362c5cb98dacc

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.9-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 64994c68796d93cdba42f37e0c073fb8ed6f9d6707232be0ba84f24dc5a36bbb
MD5 0330b3723023df66ee4980e27ca8f1ce
BLAKE2b-256 bb074eef5a5c43221470af3a9e12fce024c5b9451618c4307c7980c2d6e298b3

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.9-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3fb7c84f7c182cb5208e7bc1c104b817a3ca1a8fe111d4d19816be0d6e1ab396
MD5 485e79ea970d10f03528c7ed8b5d3a80
BLAKE2b-256 648991796feec4bbfd7539a0f773f2c9bc83c0138bcb585d94114099bcfa7bf6

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: OpenCC-1.1.9-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for OpenCC-1.1.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 84e35e5ecfad445a64c0dcd6567d9e9f3a6aed9a6ffd89cdbc071f36cb9e089e
MD5 809902abf5237621b2c7f3b39042d337
BLAKE2b-256 4708f311ac5422ddc51c3294be76f2b03f701458e6929efc0ac30f5cc9b11f90

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.9-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92769f9a60301574c73096f9ab8a9060fe0d13a9f8266735d82a2a3a92adbd26
MD5 4eb3c8b8a167552af296f4cb37f141ac
BLAKE2b-256 48dd9cf7897483f530a174b626e06d1ff3b0d074541547f84b2e221755311ea6

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.9-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a33941dd4cb67457e6f44dfe36dddc30a602363a4f6a29b41d79b062b332c094
MD5 ed52785174a96e839d25cacc4bd2f682
BLAKE2b-256 dfd0e17c4251f7981d5b5f5b6250e6a282170b57fe4a188b8966c1978c16fb5b

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: OpenCC-1.1.9-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for OpenCC-1.1.9-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b4c36d6974afd94b444ad5ad17364f40d228092ce89b86e46653f7ff38075201
MD5 22e61bf0bfd4fa618421414d8fde31a6
BLAKE2b-256 578396c2133a6c2b7b2dd441e1e76a7087e02d9a40c83a90aec817fe26fc1c00

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.9-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 436c43e0855b4f9c9e4fd1191e8ac638e9d9f2c7e2d5753952e6e31aa231d36c
MD5 6195a51fea5208915e62a5658ce01fb9
BLAKE2b-256 3d246db1dcee505f0a35974bcfb67e199198081b594358ed54af51c2109d1b6f

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.9-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4d66473405c2e360ef346fe1625f201f3f3c4adbb16d5c1c7749a150ae42d875
MD5 661eb4e9832e457e0f1b4fb34697a6da
BLAKE2b-256 d0d1561ff2934cefdd61367d5f1c8fade111e943a2636526aac72155815b74db

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: OpenCC-1.1.9-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for OpenCC-1.1.9-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a6c2650bd3d6a9e3c31fc2057e0f36122c9507af1661627542f618c97d420293
MD5 df361a12ec4bd382f6ee59339d195281
BLAKE2b-256 7ea75338e680e7f8e1372d042c4e948bc98c922b64b7637835ca91e1db404465

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.9-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c6d5f9756ed08e67de36c53dc4d8f0bdc72889d6f57a8fc4d8b073d99c58d4dc
MD5 13b08f898c962dc35cb2980a6b741e1e
BLAKE2b-256 eae43076b834fa58e6b946b25f0e7079d343776f6c5ab6312a2d722090dce207

See more details on using hashes here.

File details

Details for the file OpenCC-1.1.9-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.9-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f4267b66ed6e656b5d8199f94e9673950ac39d49ebaf0e7927330801f06f038f
MD5 e154f00b0a76ffd2d884f4d317e9a96a
BLAKE2b-256 12957ad360f2d1baa498bceb329c7ab92829409893b2c60f1844b75d2c32b406

See more details on using hashes here.

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