node-opencc
Advanced tools
Comparing version 0.0.2 to 1.0.0
@@ -0,0 +0,0 @@ { |
@@ -2849,2 +2849,6 @@ 㐷 傌 | ||
龟 龜 | ||
鿎 䃮 | ||
鿏 䥑 | ||
鿒 鿓 | ||
鿔 鎶 | ||
𠀾 𠁞 | ||
@@ -3878,1 +3882,19 @@ 𠆲 儣 | ||
𫠜 齯 | ||
𫢸 僤 | ||
𫮃 墠 | ||
𫰛 娙 | ||
𫶇 嵽 | ||
𫷷 廞 | ||
𫸩 彄 | ||
𬀩 暐 | ||
𬬭 錀 | ||
𬬻 鑪 | ||
𬭊 𨧀 | ||
𬭛 𨨏 | ||
𬭳 𨭎 | ||
𬭶 𨭆 | ||
𬶋 鮈 | ||
𬶍 鮀 | ||
𬶏 鮠 | ||
𬶟 鯻 | ||
𬸪 鷭 |
@@ -58,2 +58,3 @@ 㑮 𫝈 | ||
䂎 𥎝 | ||
䃮 鿎 | ||
䅐 𫀨 | ||
@@ -122,2 +123,3 @@ 䅳 𫀬 | ||
䥇 䦂 | ||
䥑 鿏 | ||
䥗 𫔋 | ||
@@ -2879,2 +2881,3 @@ 䥩 𨱖 | ||
鋼 钢 | ||
錀 𬬭 | ||
錁 锞 | ||
@@ -2973,2 +2976,3 @@ 錂 𨱋 | ||
鎵 镓 | ||
鎶 鿔 | ||
鎷 𨰾 | ||
@@ -3053,2 +3057,3 @@ 鎸 镌 | ||
鑥 镥 | ||
鑪 𬬻 | ||
鑭 镧 | ||
@@ -3836,2 +3841,3 @@ 鑰 钥 | ||
鿁 䜤 | ||
鿓 鿒 | ||
𠁞 𠀾 | ||
@@ -4034,5 +4040,7 @@ 𠌥 𠆿 | ||
𨦫 䦀 | ||
𨧀 𬭊 | ||
𨧜 䦁 | ||
𨧰 𫟽 | ||
𨧱 𨱊 | ||
𨨏 𬭛 | ||
𨨛 𫓼 | ||
@@ -4044,2 +4052,4 @@ 𨨢 𫓿 | ||
𨬖 𫔏 | ||
𨭆 𬭶 | ||
𨭎 𬭳 | ||
𨭖 𫔑 | ||
@@ -4046,0 +4056,0 @@ 𨭸 𫔐 |
@@ -49,8 +49,11 @@ PN結 PN接面 | ||
內聯函數 行內函數 | ||
全局 全域性 | ||
全角 全形 | ||
兼容 相容 | ||
冒泡排序 氣泡排序 | ||
函數 函式 | ||
函數式編程 函數語言程式設計 | ||
刀片服務器 刀鋒伺服器 | ||
分佈式 分散式 | ||
分區 分割槽 | ||
分辨率 解析度 | ||
@@ -67,2 +70,4 @@ 刷新 重新整理 | ||
卸載 解除安裝 | ||
原代碼 原始碼 | ||
參數 引數 | ||
參數表 參數列 | ||
@@ -79,2 +84,3 @@ 句柄 控制代碼 | ||
回調 回撥 | ||
固件 韌體 | ||
圖像 影象 | ||
@@ -86,3 +92,4 @@ 圖庫 相簿 | ||
地址欄 位址列 | ||
城域王 都會網路 | ||
城域網 都會網路 | ||
堆棧 堆疊 | ||
場效應管 場效電晶體 | ||
@@ -98,2 +105,3 @@ 壁紙 桌布 壁紙 | ||
字符 字元 | ||
字符串 字串 | ||
字符集 字符集 | ||
@@ -104,3 +112,5 @@ 字節 位元組 | ||
存盤 存檔 | ||
宏 巨集 | ||
宏內核 單核心 | ||
寄存器 暫存器 | ||
密鑰 金鑰 | ||
@@ -118,5 +128,7 @@ 實例 例項 實例 | ||
局域網 區域網 | ||
局部 區域性 | ||
屏幕 螢幕 | ||
屏蔽 遮蔽 | ||
嵌套 巢狀 | ||
布爾 布林 | ||
帶寬 頻寬 | ||
@@ -135,3 +147,5 @@ 引導程序 載入程式 | ||
打開 開啟 打開 | ||
拋出 丟擲 | ||
持久性 永續性 | ||
指針 指標 | ||
捲積 摺積 | ||
@@ -143,5 +157,6 @@ 掃描儀 掃描器 | ||
接口 介面 | ||
控件 控制項 | ||
控件 控制元件 | ||
插件 外掛 | ||
搜索 搜尋 | ||
操作數 運算元 | ||
操作系統 作業系統 | ||
@@ -188,2 +203,3 @@ 擴展 擴充套件 | ||
構造函數 建構函式 | ||
標識符 識別符號 | ||
模塊 模組 | ||
@@ -205,2 +221,3 @@ 模擬 模擬 類比 | ||
源文件 原始檔 | ||
源碼 原始碼 | ||
溢出 溢位 | ||
@@ -256,2 +273,3 @@ 演示文稿 簡報 | ||
網上鄰居 網路上的芳鄰 | ||
網卡 網絡卡 | ||
網吧 網咖 | ||
@@ -271,2 +289,3 @@ 網絡 網路 | ||
聲卡 音效卡 | ||
聲明 宣告 | ||
脫機 離線 | ||
@@ -283,3 +302,3 @@ 腳本 指令碼 | ||
虛擬機 虛擬機器 | ||
表達式 表示式 | ||
表達式 表示式 運算式 | ||
複印 影印 | ||
@@ -306,3 +325,3 @@ 複選按鈕 覈取按鈕 | ||
調製解調器 數據機 | ||
調試 偵錯 | ||
調試 除錯 偵錯 | ||
調試器 偵錯程式 | ||
@@ -314,5 +333,8 @@ 變量 變數 | ||
通訊卡 通話卡 | ||
通配符 萬用字元 | ||
連接 連線 | ||
連接器 聯結器 | ||
進制 進位制 | ||
進程 程序 進程 | ||
運算符 運算子 | ||
運行 執行 | ||
@@ -347,5 +369,8 @@ 過程式編程 程序式程式設計 | ||
頁腳 頁尾 | ||
項目 專案 | ||
預處理器 前處理器 | ||
頭文件 標頭檔案 | ||
頻分多址 分頻多重進接 | ||
頻分複用 分頻多工 | ||
類型 型別 | ||
類模板 類别範本 | ||
@@ -352,0 +377,0 @@ 顯像管 映象管 |
@@ -10,2 +10,3 @@ 元音 母音 | ||
硅 矽 | ||
納米 奈米 | ||
詞組 片語 | ||
@@ -12,0 +13,0 @@ 蹦極 笨豬跳 |
@@ -8,4 +8,6 @@ 僞 偽 | ||
幺 么 | ||
擡 抬 | ||
曬 晒 | ||
棱 稜 | ||
檐 簷 | ||
污 汙 | ||
@@ -24,2 +26,3 @@ 泄 洩 | ||
糉 粽 | ||
繮 韁 | ||
纔 才 | ||
@@ -32,3 +35,5 @@ 羣 群 | ||
踊 踴 | ||
鉢 缽 | ||
鮎 鯰 | ||
麪 麵 | ||
齶 顎 |
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "0.0.2", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
@@ -16,11 +16,10 @@ "repository": { | ||
"engines": { | ||
"node": ">= 4.0" | ||
"node": ">= 7.6.0" | ||
}, | ||
"scripts": { | ||
"refresh": "node scripts/download-opencc-database.js", | ||
"download": "node scripts/download-opencc-database.js && npm test", | ||
"test": "mocha" | ||
}, | ||
"main": "src/index.js", | ||
"main": "lib/index.js", | ||
"devDependencies": { | ||
"bluebird": "^3.3.1", | ||
"mkdirp": "^0.5.1", | ||
@@ -27,0 +26,0 @@ "mocha": "^2.4.5", |
@@ -10,4 +10,5 @@ # Translates between Traditional and Simplified Chinese in pure Node.js [![Build Status](https://travis-ci.org/compulim/node-opencc.svg?branch=master)](https://travis-ci.org/compulim/node-opencc) | ||
## Usage | ||
You can only access `node-opencc` programmatically. Since dictionaries are huge, they are loaded asynchronously with Promise interface. Thus, all translations on `node-opencc` will return `thenable`. | ||
You can only access `node-opencc` programmatically. Since dictionaries are huge, they are loaded asynchronously with Promise interface. Thus, all translations on `node-opencc` will be completed in Promise fashion. | ||
For example, | ||
@@ -18,7 +19,8 @@ | ||
opencc.hongKongToSimplified('滑鼠').then(result => result === '鼠标'); | ||
opencc.traditionalToHongKong('僞').then(result => result === '偽'); | ||
await opencc.hongKongToSimplified('滑鼠') === '鼠标'; | ||
await opencc.traditionalToHongKong('僞') === '偽'; | ||
``` | ||
`node-opencc` supports multiple type of translations: | ||
* Hong Kong to Simplified Chinese (`hongKongToSimplified`) | ||
@@ -39,7 +41,10 @@ * Simplified Chinese to Hong Kong (`simplifiedToHongKong`) | ||
* Multiple alternative phrases, verbs, and characters | ||
* Use `withPhrases` options | ||
## Changelog | ||
* 2016-02-25 (0.0.2): First public release | ||
Please refer to change log [here](CHANGELOG.md). | ||
## Contribution | ||
You may want to head to [OpenCC](https://github.com/byvoid/opencc) for dictionary contribution. | ||
@@ -46,0 +51,0 @@ |
'use strict'; | ||
const | ||
fetch = require('node-fetch'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
Promise = require('bluebird'); | ||
const fetch = require('node-fetch'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const mkdirp = require('./util/mkdirp'); | ||
const writeFile = require('./util/writeFile'); | ||
const | ||
mkdirp = Promise.promisify(require('mkdirp')), | ||
writeFile = Promise.promisify(fs.writeFile); | ||
const BASE_URL = 'https://raw.githubusercontent.com/BYVoid/OpenCC/master/'; | ||
const OUTPUT_PATH = path.resolve(__dirname, '../opencc-database'); | ||
const FILENAMES = [ | ||
'data/config/hk2s.json', | ||
'data/config/hk2s.json', | ||
'data/config/s2hk.json', | ||
'data/config/s2t.json', | ||
'data/config/s2tw.json', | ||
'data/config/s2twp.json', | ||
'data/config/t2hk.json', | ||
'data/config/t2s.json', | ||
'data/config/t2tw.json', | ||
'data/config/tw2s.json', | ||
'data/config/tw2sp.json', | ||
'data/dictionary/HKVariants.txt', | ||
'data/dictionary/HKVariantsPhrases.txt', | ||
'data/dictionary/HKVariantsRevPhrases.txt', | ||
'data/dictionary/JPVariants.txt', | ||
'data/dictionary/STCharacters.txt', | ||
'data/dictionary/STPhrases.txt', | ||
'data/dictionary/TSCharacters.txt', | ||
'data/dictionary/TSPhrases.txt', | ||
'data/dictionary/TWPhrasesIT.txt', | ||
'data/dictionary/TWPhrasesName.txt', | ||
'data/dictionary/TWPhrasesOther.txt', | ||
'data/dictionary/TWVariants.txt', | ||
'data/dictionary/TWVariantsRevPhrases.txt', | ||
'test/testcases/hk2s.ans', | ||
'test/testcases/hk2s.in', | ||
'test/testcases/s2hk.ans', | ||
'test/testcases/s2hk.in', | ||
'test/testcases/s2t.ans', | ||
'test/testcases/s2t.in', | ||
'test/testcases/s2tw.ans', | ||
'test/testcases/s2tw.in', | ||
'test/testcases/s2twp.ans', | ||
'test/testcases/s2twp.in', | ||
'test/testcases/t2s.ans', | ||
'test/testcases/t2s.in', | ||
'test/testcases/tw2s.ans', | ||
'test/testcases/tw2s.in', | ||
'test/testcases/tw2sp.ans', | ||
'test/testcases/tw2sp.in' | ||
]; | ||
const | ||
BASE_URL = 'https://raw.githubusercontent.com/BYVoid/OpenCC/master/', | ||
OUTPUT_PATH = path.resolve(module.filename, '../../opencc-database'), | ||
URLS = [ | ||
'data/config/hk2s.json', | ||
'data/config/hk2s.json', | ||
'data/config/s2hk.json', | ||
'data/config/s2t.json', | ||
'data/config/s2tw.json', | ||
'data/config/s2twp.json', | ||
'data/config/t2hk.json', | ||
'data/config/t2s.json', | ||
'data/config/t2tw.json', | ||
'data/config/tw2s.json', | ||
'data/config/tw2sp.json', | ||
'data/dictionary/HKVariants.txt', | ||
'data/dictionary/HKVariantsPhrases.txt', | ||
'data/dictionary/HKVariantsRevPhrases.txt', | ||
'data/dictionary/JPVariants.txt', | ||
'data/dictionary/STCharacters.txt', | ||
'data/dictionary/STPhrases.txt', | ||
'data/dictionary/TSCharacters.txt', | ||
'data/dictionary/TSPhrases.txt', | ||
'data/dictionary/TWPhrasesIT.txt', | ||
'data/dictionary/TWPhrasesName.txt', | ||
'data/dictionary/TWPhrasesOther.txt', | ||
'data/dictionary/TWVariants.txt', | ||
'data/dictionary/TWVariantsRevPhrases.txt', | ||
'test/testcases/hk2s.ans', | ||
'test/testcases/hk2s.in', | ||
'test/testcases/s2hk.ans', | ||
'test/testcases/s2hk.in', | ||
'test/testcases/s2t.ans', | ||
'test/testcases/s2t.in', | ||
'test/testcases/s2tw.ans', | ||
'test/testcases/s2tw.in', | ||
'test/testcases/s2twp.ans', | ||
'test/testcases/s2twp.in', | ||
'test/testcases/t2s.ans', | ||
'test/testcases/t2s.in', | ||
'test/testcases/tw2s.ans', | ||
'test/testcases/tw2s.in', | ||
'test/testcases/tw2sp.ans', | ||
'test/testcases/tw2sp.in' | ||
]; | ||
async function main() { | ||
await Promise.all(FILENAMES.map(filename => downloadFile(filename))); | ||
} | ||
Promise.all(URLS.map(url => | ||
fetch(BASE_URL + url) | ||
.then(res => { | ||
const status = res.status; | ||
async function downloadFile(filename) { | ||
const res = await fetch(BASE_URL + filename); | ||
const { status } = res; | ||
if (status === 200) { | ||
return res.text(); | ||
} else { | ||
throw new Error(`Server returned ${status}`); | ||
} | ||
}) | ||
.then(text => { | ||
const filename = path.resolve(OUTPUT_PATH, url); | ||
if (status !== 200) { | ||
throw new Error(`Server returned ${status}`); | ||
} | ||
return mkdirp(path.dirname(filename)) | ||
.then(() => writeFile(filename, text)) | ||
}) | ||
)).catch(err => { | ||
console.error(err); | ||
process.exit(-1); | ||
}); | ||
const text = await res.text(); | ||
const outputFilename = path.join(OUTPUT_PATH, filename); | ||
await mkdirp(path.dirname(outputFilename)); | ||
await writeFile(outputFilename, text); | ||
} | ||
main(); |
'use strict'; | ||
const | ||
assert = require('assert'), | ||
fs = require('fs'), | ||
opencc = require('../src/index'), | ||
path = require('path'), | ||
Promise = require('bluebird'); | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const opencc = require(`../${ require('../package.json').main }`); | ||
const path = require('path'); | ||
const readFile = require('../lib/util/readFile'); | ||
const | ||
readFile = Promise.promisify(fs.readFile); | ||
describe('Convert based on OpenCC tests', function () { | ||
@@ -48,3 +44,3 @@ it('should convert Hong Kong to Simplified Chinese', function (done) { | ||
function readTestFile(filename) { | ||
return readFile(path.resolve(module.filename, '../../opencc-database/test/testcases/', filename), 'utf8'); | ||
return readFile(path.join(__dirname, '../opencc-database/test/testcases/', filename), 'utf8'); | ||
} | ||
@@ -51,0 +47,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1117952
3
53
631
1
56
6