Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include LICENSE.txt
include README.md
recursive-include opencc *.txt *.py
recursive-include opencc *.txt *.py *.json
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,27 @@ See https://docs.python.org/3/library/codecs.html#standard-encodings for list of

### Conversions 轉換

* `hk2s`: Traditional Chinese (Hong Kong standard) to Simplified Chinese
* `hk2s`: Traditional Chinese (Hong Kong variant) to Simplified Chinese

* `s2hk`: Simplified Chinese to Traditional Chinese (Hong Kong standard)
* `hk2sp`: Traditional Chinese (Hong Kong variant) to Simplified Chinese (with phrases)

* `hk2t`: Traditional Chinese (Hong Kong variant) to Traditional Chinese

* `jp2t`: New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai)

* `s2hk`: Simplified Chinese to Traditional Chinese (Hong Kong variant)

* `s2hkp`: Simplified Chinese to Traditional Chinese (Hong Kong variant, with phrases)

* `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)
* `t2hk`: Traditional Chinese to Traditional Chinese (Hong Kong variant)

* `t2jp`: Traditional Chinese Characters (Kyūjitai) to New Japanese Kanji (Shinjitai)

* `t2s`: Traditional Chinese to Simplified Chinese

Expand All @@ -94,6 +104,8 @@ See https://docs.python.org/3/library/codecs.html#standard-encodings for list of

* `tw2sp`: Traditional Chinese (Taiwan standard) to Simplified Chinese (with phrases)

* `tw2t`: Traditional Chinese (Taiwan standard) to Traditional Chinese

## Issues 問題

當轉換有兩個以上的字詞可能時,程式只會使用第一個。
Expand Down
49 changes: 0 additions & 49 deletions helper/merge.py

This file was deleted.

10 changes: 0 additions & 10 deletions helper/readme.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
merge.py
for merging dictionary files into a single file (requires Python3)

merge 'TWPhrasesIT.txt', 'TWPhrasesName.txt', and 'TWPhrasesOther.txt'
into a single file 'TWPhrases.txt'

Run:
python3 merge.py


reverse.py
for reversing dictionary keys and values (requires Python3)

Expand Down
8 changes: 7 additions & 1 deletion helper/reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
REV_INPUTS = [
'TWVariants',
'TWPhrases',
'HKVariants'
'HKVariants',
'JPShinjitaiCharacters'
]


Expand All @@ -36,13 +37,18 @@ def reverse(rev_inputs=REV_INPUTS):
with open(input_file, 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
# Skip blank lines and upstream comment/header lines
if not line or line.startswith('#'):
continue
split = line.split('\t')
if len(split) < 2:
continue
term1 = split[0]
term2 = split[1]

for char in term2.split(' '):
if not char:
continue
if char in reversed_dict:
reversed_dict[char].append(term1)
else:
Expand Down
36 changes: 36 additions & 0 deletions opencc/config/hk2sp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "Traditional Chinese (Hong Kong variant) to Simplified Chinese (with phrases)",
"segmentation": {
"type": "mmseg",
"dict": {
"type": "txt",
"file": "TSPhrases.txt"
}
},
"conversion_chain": [{
"dict": {
"type": "group",
"dicts": [{
"type": "txt",
"file": "HKPhrasesRev.txt"
}, {
"type": "txt",
"file": "HKVariantsRevPhrases.txt"
}, {
"type": "txt",
"file": "HKVariantsRev.txt"
}]
}
}, {
"dict": {
"type": "group",
"dicts": [{
"type": "txt",
"file": "TSPhrases.txt"
}, {
"type": "txt",
"file": "TSCharacters.txt"
}]
}
}]
}
2 changes: 1 addition & 1 deletion opencc/config/hk2t.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Traditional Chinese (Hong Kong variant) to Traditional Chinese",
"name": "Traditional Chinese (Hong Kong variant) to Traditional Chinese (OpenCC Standard)",
"segmentation": {
"type": "mmseg",
"dict": {
Expand Down
3 changes: 0 additions & 3 deletions opencc/config/jp2t.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
}, {
"type": "txt",
"file": "JPShinjitaiCharacters.txt"
}, {
"type": "txt",
"file": "JPVariantsRev.txt"
}]
}
}]
Expand Down
36 changes: 36 additions & 0 deletions opencc/config/s2hkp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "Simplified Chinese to Traditional Chinese (Hong Kong variant, with phrases)",
"segmentation": {
"type": "mmseg",
"dict": {
"type": "txt",
"file": "STPhrases.txt"
}
},
"conversion_chain": [{
"dict": {
"type": "group",
"dicts": [{
"type": "txt",
"file": "STPhrases.txt"
}, {
"type": "txt",
"file": "STCharacters.txt"
}]
}
}, {
"dict": {
"type": "group",
"dicts": [{
"type": "txt",
"file": "HKPhrases.txt"
}, {
"type": "txt",
"file": "HKVariantsPhrases.txt"
}, {
"type": "txt",
"file": "HKVariants.txt"
}]
}
}]
}
4 changes: 2 additions & 2 deletions opencc/config/t2jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"type": "mmseg",
"dict": {
"type": "txt",
"file": "JPVariants.txt"
"file": "JPShinjitaiCharactersRev.txt"
}
},
"conversion_chain": [{
"dict": {
"type": "txt",
"file": "JPVariants.txt"
"file": "JPShinjitaiCharactersRev.txt"
}
}]
}
2 changes: 1 addition & 1 deletion opencc/config/tw2t.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Traditional Chinese (Taiwan standard) to Traditional Chinese",
"name": "Traditional Chinese (Taiwan Standard) to Traditional Chinese (OpenCC Standard)",
"segmentation": {
"type": "mmseg",
"dict": {
Expand Down
46 changes: 46 additions & 0 deletions opencc/dictionary/HKPhrases.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: HKPhrases.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: s2hkp.json (via HKPhrases.ocd2)

伊利諾伊 伊利諾
伊利諾伊州 伊利諾州
俄克拉何馬 奧克拉荷馬
俄克拉何馬州 奧克拉荷馬州
俄克拉荷馬 奧克拉荷馬
俄克拉荷馬州 奧克拉荷馬州
光標 游標
北卡羅來納 北卡羅萊納
北卡羅來納州 北卡羅萊納州
南卡羅來納 南卡羅萊納
南卡羅來納州 南卡羅萊納州
密歇根 密芝根
密歇根州 密芝根州
寬帶 寬頻
幾率 機率 概率
弗吉尼亞 維珍尼亞
弗吉尼亞州 維珍尼亞州
得克薩斯 德薩斯
得克薩斯州 德薩斯州
德克薩斯 德薩斯
德克薩斯州 德薩斯州
搜索 搜尋
操作系統 作業系統
文件夾 資料夾
服務器 伺服器
概率 概率 機會率
硬盤 硬碟
編程語言 程式語言
羅得島 羅德島
羅得島州 羅德島州
舒芙蕾 梳芙厘
西弗吉尼亞 西維珍尼亞
西弗吉尼亞州 西維珍尼亞州
賓夕法尼亞 賓夕凡尼亞
賓夕法尼亞州 賓夕凡尼亞州
隱私權 私隱權
馬里蘭 馬利蘭
馬里蘭州 馬利蘭州
鼠標 滑鼠
43 changes: 43 additions & 0 deletions opencc/dictionary/HKPhrasesRev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Open Chinese Convert (OpenCC) Dictionary
# File: HKPhrasesRev.txt
# Format: key value(s) (values separated by spaces)
# License: Apache-2.0 (see LICENSE)
# Source: https://github.com/ByVoid/OpenCC
# Used in configs: hk2sp.json (via HKPhrasesRev.ocd2)

伊利諾 伊利諾伊
伊利諾州 伊利諾伊州
伺服器 服務器
作業系統 操作系統
北卡羅萊納 北卡羅來納
北卡羅萊納州 北卡羅來納州
南卡羅萊納 南卡羅來納
南卡羅萊納州 南卡羅來納州
奧克拉荷馬 俄克拉何馬 俄克拉荷馬
奧克拉荷馬州 俄克拉何馬州 俄克拉荷馬州
密芝根 密歇根
密芝根州 密歇根州
寬頻 寬帶
德薩斯 得克薩斯 德克薩斯
德薩斯州 得克薩斯州 德克薩斯州
搜尋 搜索
梳芙厘 舒芙蕾
概率 概率 幾率
機會率 概率
機率 幾率
游標 光標
滑鼠 鼠標
硬碟 硬盤
私隱權 隱私權
程式語言 編程語言
維珍尼亞 弗吉尼亞
維珍尼亞州 弗吉尼亞州
羅德島 羅得島
羅德島州 羅得島州
西維珍尼亞 西弗吉尼亞
西維珍尼亞州 西弗吉尼亞州
資料夾 文件夾
賓夕凡尼亞 賓夕法尼亞
賓夕凡尼亞州 賓夕法尼亞州
馬利蘭 馬里蘭
馬利蘭州 馬里蘭州
Loading