-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #1: publish this repo as an NPM package
- Loading branch information
Showing
3 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Node.js Package | ||
on: | ||
release: | ||
types: [created] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: | | ||
npm install --global rollup | ||
cd js | ||
rollup zdict.js --format umd --name zDict --file zdict2.js | ||
mv zdict2.js zdict.js | ||
# rollup data-chars.js --format cjs --file data-chars2.js | ||
# rollup data-freqs.js --format cjs --file data-freqs2.js | ||
cd .. | ||
rm -r R/ data/ *.Rproj | ||
npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,40 @@ | ||
# zdict | ||
# zdict.js | ||
|
||
汉字、拼音、释义等数据。 | ||
|
||
目前包含: | ||
|
||
- 从汉典网站抓取的[七千通用汉字](https://www.zdic.net/zd/zb/ty/)及其拼音、基本释义,存放在 [js/data-chars.js](js/data-chars.js) 文件中。抓这些数据的初衷是为了[辅助小朋友识字](https://yihui.org/cn/kids/2021/02/chars/)。 | ||
- 汉字频度表 [js/data-freqs.js](js/data-freqs.js)([数据来源](https://web.archive.org/web/20120711003705/http://onlinechinese2u.com/blog/wp-content/uploads/2012/04/LEGOO-MANDARIN-%E6%B1%89%E5%AD%97%E9%A2%91%E5%BA%A6%E8%A1%A8%E7%BB%9F%E8%AE%A1.pdf)) | ||
- 从汉典网站抓取的[七千通用汉字](https://www.zdic.net/zd/zb/ty/)及其拼音、基本释义,存放在 | ||
[js/data-chars.js](js/data-chars.js) | ||
文件中。抓这些数据的初衷是为了[辅助小朋友识字](https://yihui.org/cn/kids/2021/02/chars/)。 | ||
- 汉字频度表 | ||
[js/data-freqs.js](js/data-freqs.js)([数据来源](https://web.archive.org/web/20120711003705/http://onlinechinese2u.com/blog/wp-content/uploads/2012/04/LEGOO-MANDARIN-%E6%B1%89%E5%AD%97%E9%A2%91%E5%BA%A6%E8%A1%A8%E7%BB%9F%E8%AE%A1.pdf)) | ||
|
||
## 中文识字应用 | ||
|
||
HTML 页面上创建一个 `id` 为 `leanr-chars` 的 `<div>` 容器,再加载 JS 脚本和 | ||
CSS,即可生成一个中文识字应用界面。若页面内不存在这个容器,那么界面将在 JS | ||
脚本之后创建。参见这里的[示例页面](https://yihui.org/cn/kids/2021/02/chars/)。 | ||
|
||
``` html | ||
<div id="learn-chars"></div> | ||
|
||
<link href="https://cdn.jsdelivr.net/npm/@xiee/zdict/css/learn-chars.min.css" rel="stylesheet"></link> | ||
<script src="https://cdn.jsdelivr.net/npm/@xiee/zdict/js/zdict.min.js" defer></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@xiee/zdict/js/learn-chars.min.js" defer></script> | ||
``` | ||
|
||
## 汉字数据 | ||
|
||
若想单独加载数据模块,可以在 JS 中 `import` 导入或者在 Node 中 `require()` 加载 | ||
`zdict.js`,其包含两个成员:`chars` 是七千通用汉字数据,`freqs` | ||
是按频度排序的七千汉字。 | ||
|
||
``` javascript | ||
const zDict = require('@xiee/zdict'); | ||
zDict.chars['一']; | ||
zDict.freqs; | ||
``` | ||
|
||
若在浏览器中加载上述 `jsdelivr` 中的 `zdict.min.js` 那么会得到一个全局对象 | ||
`zDict`。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "@xiee/zdict", | ||
"version": "1.0.0", | ||
"description": "汉典网站数据(通用汉字、拼音、释义等)", | ||
"main": "js/zdict.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/yihui/zdict.js.git" | ||
}, | ||
"keywords": [ | ||
"chinese characters", | ||
"zdic.net", | ||
"pinyin" | ||
], | ||
"author": "Yihui Xie <[email protected]> (https://yihui.org)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/yihui/zdict.js/issues" | ||
}, | ||
"homepage": "https://github.com/yihui/zdict.js#readme" | ||
} |