Skip to main content

Conversion between Traditional and Simplified Chinese

Project description

Open Chinese Convert 開放中文轉換

Travis AppVeyor C/C++ CI Node.js CI Python CI

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 安裝

See Download.

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

PyPI 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;
}

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

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 的項目

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

OpenCC-1.1.7-cp312-cp312-win_amd64.whl (716.5 kB view details)

Uploaded CPython 3.12 Windows x86-64

OpenCC-1.1.7-cp312-cp312-manylinux1_x86_64.whl (779.7 kB view details)

Uploaded CPython 3.12

OpenCC-1.1.7-cp312-cp312-macosx_10_9_x86_64.whl (735.7 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

OpenCC-1.1.7-cp311-cp311-win_amd64.whl (715.9 kB view details)

Uploaded CPython 3.11 Windows x86-64

OpenCC-1.1.7-cp311-cp311-manylinux1_x86_64.whl (779.7 kB view details)

Uploaded CPython 3.11

OpenCC-1.1.7-cp311-cp311-macosx_10_9_x86_64.whl (734.8 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

OpenCC-1.1.7-cp310-cp310-win_amd64.whl (716.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

OpenCC-1.1.7-cp310-cp310-manylinux1_x86_64.whl (779.8 kB view details)

Uploaded CPython 3.10

OpenCC-1.1.7-cp310-cp310-macosx_10_9_x86_64.whl (734.8 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

OpenCC-1.1.7-cp39-cp39-win_amd64.whl (716.1 kB view details)

Uploaded CPython 3.9 Windows x86-64

OpenCC-1.1.7-cp39-cp39-manylinux1_x86_64.whl (779.9 kB view details)

Uploaded CPython 3.9

OpenCC-1.1.7-cp39-cp39-macosx_10_9_x86_64.whl (734.9 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

OpenCC-1.1.7-cp38-cp38-win_amd64.whl (715.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

OpenCC-1.1.7-cp38-cp38-manylinux1_x86_64.whl (779.8 kB view details)

Uploaded CPython 3.8

OpenCC-1.1.7-cp38-cp38-macosx_10_9_x86_64.whl (734.8 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: OpenCC-1.1.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 716.5 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for OpenCC-1.1.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7f3f843f0b47afa0bff91ea5b9fbf9968f19ffbaffda9508615993058246ca3c
MD5 594f12bbc33fc6681b9e47b0403bca3b
BLAKE2b-256 71661d56f4cf2c80243d3f8e715bfd81a2e4413691e9a8a2e07c827d7e2f6596

See more details on using hashes here.

Provenance

File details

Details for the file OpenCC-1.1.7-cp312-cp312-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.7-cp312-cp312-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 dc5d6443b833e1a45bcad4d4312c680d9d574a365491357165d927a3eecac5f0
MD5 64dce45e8133bda58b4b61fb1ec47c84
BLAKE2b-256 925a7b1cd306d435434058ea4a97467f0f2e74408ed54be4b2ae3d40d337ab5b

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for OpenCC-1.1.7-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 253e7d636ad0aad2e70e616d2185181e0104687f53ec38974f7b67221c475382
MD5 622b57730d11d843699fb9b1a2a07eb3
BLAKE2b-256 688695196525a59c440d03b182e638f1cd0ad2b74e2e41e37c6f931b4bb85fd7

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: OpenCC-1.1.7-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 715.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for OpenCC-1.1.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d2d4705b3f599903784b4d4be6a557c591aeeb93d2b99b8f19d3e13dee4fab10
MD5 ed659c6405eb6788ca4f9f58e43a98f3
BLAKE2b-256 f076a9a5cedb776401a5ac470fb92be910012410d6334693e4799b2544493de5

See more details on using hashes here.

Provenance

File details

Details for the file OpenCC-1.1.7-cp311-cp311-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.7-cp311-cp311-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3ed6f128383375b9dc5c3db02ffa9d6ac1a14242656414bab85a18ef65daf645
MD5 1ed255db1a0f31bb5b0f996c593255db
BLAKE2b-256 18a29ccfc1e1c49f6643b2bc090ba2a5bca5df6a2754e5049caa1909609bdccd

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for OpenCC-1.1.7-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8aa4b1203bf78ced40ae4da7206089ccd459f823a1b05f311b653eb08dce7d0d
MD5 e91656462a78e3fcbe7136f06e63cdfb
BLAKE2b-256 a2999bf06f2111f682ce8c1cf6b57a01b651b0c9d786e7d650b1f7cb6ac0d6a2

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: OpenCC-1.1.7-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 716.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for OpenCC-1.1.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8fa764bbb93ff97f50d1f70ca2542c9108adb763845d690e256664a61c98f914
MD5 47e94e4b78a38e601e0f129b8e769941
BLAKE2b-256 0c89aaae6b007603e5021a3b7dc0f53835cad9065999f342a9ed4d7779dd0c9b

See more details on using hashes here.

Provenance

File details

Details for the file OpenCC-1.1.7-cp310-cp310-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.7-cp310-cp310-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fc4fb3ec08dcbdb430cbd70d14f9457f2b2ef2d51b08bf079b9cee0c6def3eed
MD5 b424b0c906276496f6607d154ddb1a82
BLAKE2b-256 df273d4652dcf73d1ddde83348ab167dc33372822f96eac76fd6235d5144868a

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for OpenCC-1.1.7-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ba77d5eb376129adcad090a07b0edbee293f26513f14a135a9cb17af004defd1
MD5 1a4f6e1ac61426684bfbfeff99bfa428
BLAKE2b-256 0a28aed41e348d84cefbacd80e8715969c3acbbf0d849335ef924946655960d7

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: OpenCC-1.1.7-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 716.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for OpenCC-1.1.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6455d2548e2211d28cfa68d25aceeb4ff06c6a396264dcefe5a2b885ffeaf783
MD5 59601077947fc16095a7a1b932053a0b
BLAKE2b-256 58e09adbd3983da5bf627a097dbfb81acfa02d68e6e97b8be367968b88dde6f1

See more details on using hashes here.

Provenance

File details

Details for the file OpenCC-1.1.7-cp39-cp39-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.7-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b55ad5edf93a45e89519fa4aa80384d7021fd795fdf8c9315b6898fa2a0e202a
MD5 129b439482a12b77822e49cfc64e9003
BLAKE2b-256 1fef5221cf0909fcf44e33176a89af15728b581c45a6fe5f4201ea8a5640bcda

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for OpenCC-1.1.7-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a16b7ed7d01b77b133a51e41903c5c83486de5be5483164c869ed34b9bbfdaf7
MD5 ba63ef15572fa43ebad47451ab95e181
BLAKE2b-256 e63c50b95105d0578ea519d8d586a810a67c218db496ca77efa59f849f951480

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: OpenCC-1.1.7-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 715.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for OpenCC-1.1.7-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 06092f06e4b8a1f2563df03214c9f6fa457c9ff6d114f76bf9fb374cc2a4591f
MD5 906c3164ffc5b6035802cd7b6d273f5c
BLAKE2b-256 d93c5be641241b1cb91ce65d77febcee76a8ec1a66244d2f75172212bfd692ec

See more details on using hashes here.

Provenance

File details

Details for the file OpenCC-1.1.7-cp38-cp38-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for OpenCC-1.1.7-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 49bbf40042702a743ad5b65398fc3faf1582e41fc948cd9bbbabe7c3e5366cd6
MD5 7ec46aaaef322fa59a265efb994bba7e
BLAKE2b-256 7c19b05d2c0b0f03154e68e85086e1db891b785afadfaad3901294fff6c19572

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for OpenCC-1.1.7-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 49c2eb39f636c948eaa21a84f4553da761a9cca5aa0dede8570729d572712531
MD5 cfc7734fd9d28be721acf849b454d321
BLAKE2b-256 dafded04905f54eb29459f91ee8afc10de9342a0a09fcba40dcc5bb2b272c895

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