Skip to content

Commit

Permalink
feat: v3.2.4 done
Browse files Browse the repository at this point in the history
  • Loading branch information
theajack committed Apr 9, 2023
1 parent 0bf71ce commit 2d48c24
Show file tree
Hide file tree
Showing 21 changed files with 376 additions and 92 deletions.
29 changes: 21 additions & 8 deletions README.md
Expand Up @@ -71,13 +71,13 @@

注:最新统计时间为 2023/04/08,总金额=32元

| 昵称 | 金额(元) | 时间 | 留言 | 渠道 |
|:--:|:--:|:--:|:--:|:--:|
| 普通的disco | 20 | 2023/04/01 | 大佬开源维护不易,加油!希望能有部首查字的功能~ | 微信赞赏码 |
| mango | 5 | 2023/02/10 | - | 微信赞赏码 |
| 阿炜 | 5 | 2022/11/11 | 阿炜ky2700 | 微信赞赏码 |
| slako | 1 | 2022/10/20 | 不明觉厉 | 微信赞赏码 |
| 王三金 | 1 | 2022/10/16 | - | 微信赞赏码 |
| 昵称 | 金额(元) | 时间 | 留言 | 渠道 | 作者备注 |
|:--:|:--:|:--:|:--:|:--:|:--:|
| 普通的disco | 20 | 2023/04/01 | 大佬开源维护不易,加油!希望能有部首查字的功能~ | 微信赞赏码 |v3.2.4中已增加该功能|
| mango | 5 | 2023/02/10 | - | 微信赞赏码 | |
| 阿炜 | 5 | 2022/11/11 | 阿炜ky2700 | 微信赞赏码 | |
| slako | 1 | 2022/10/20 | 不明觉厉 | 微信赞赏码 | |
| 王三金 | 1 | 2022/10/16 | - | 微信赞赏码 | |

---

Expand All @@ -87,7 +87,8 @@
<!-- toc -->

- [应用例子](#应用例子)
- [赞助](#赞助)
- [赞赏](#赞赏)
- [赞赏记录](#赞赏记录)
- [前言](#前言)
- [0.快速使用](#0快速使用)
- [1.功能](#1功能)
Expand Down Expand Up @@ -794,6 +795,8 @@ cnchar.strokeToWord(1, 'array'); // 返回 ['一', '乙']

#### 5.7 成语功能

(在线文档)[https://theajack.github.io/cnchar/doc/idiom.html]

cnchar在2.2.0加入了成语功能,启用该功能需要安装 `cnchar-idiom` 功能库,该库可以独立于cnchar主库运行

使用方式如下:
Expand All @@ -819,6 +822,8 @@ cnchar.idiom('shang4'); // ["上兵伐谋", "上不着天,下不着地", ... ]

#### 5.8 歇后语功能

(在线文档)[https://theajack.github.io/cnchar/doc/xhy.html]

cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库,该库可以独立于cnchar主库运行

使用方式如下:
Expand All @@ -844,6 +849,8 @@ cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥

#### 5.9 偏旁部首功能

(在线文档)[https://theajack.github.io/cnchar/doc/radical.html]

cnchar在 2.2.5 加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库,该库可以独立于cnchar主库运行

且于 3.2.0 版本进行了升级,支持了查询汉字结构和偏旁笔画数
Expand All @@ -864,6 +871,8 @@ cnchar.radical(text:string | Array<string>): Array<{

#### 5.10 组词功能

(在线文档)[https://theajack.github.io/cnchar/doc/words.html]

cnchar 在 3.1.0 加入了组词功能,需要安装 `cnchar-words`, 具体使用如下

args 传入 trad 可以查询繁体字,但是依赖于安装了 cnchar-trad
Expand All @@ -883,6 +892,8 @@ cnchar.words.addWords('你们好'); // 添加一个词组

#### 5.11 查询解释功能

(在线文档)[https://theajack.github.io/cnchar/doc/explain.html]

cnchar 在 3.1.0 加入了查询解释功能,需要安装 `cnchar-explain`, 具体使用如下

args 传入 trad 可以查询繁体字,但是依赖于安装了 cnchar-trad
Expand All @@ -905,6 +916,8 @@ cnchar.explain.addExplain({

#### 5.12 发音、语音合成和语音识别

(在线文档)[https://theajack.github.io/cnchar/doc/voice.html]

cnchar 在 3.1.0 加入了发音、语音合成和语音识别功能, 需要安装 `cnchar-voice`,

##### 5.12.1 voice api
Expand Down
20 changes: 20 additions & 0 deletions helper/README.en.md
Expand Up @@ -41,6 +41,26 @@ Before starting the documentation, let's take a look at some use cases to see wh

[Chinese character typing game](https://theajack.github.io/type/) | [Typing and playing the piano](https://theajack.github.io/piano/) | [Idiom Solitaire](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/idiom.js) | [Address Book Sort](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/sort.js) | [name](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/name.js) | [input method](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/input.js) | [Xie Houyu](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/xhy.js) | [Speech Recognition and Synthesis](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/voice.js) | [Simplified and Traditional Conversion](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/trad.js)

### Appreciation

Open source maintenance is not easy. If the project is helpful to you and you have spare energy, you can scan the code on WeChat and ask the author to drink a cup of cola or coffee, thank you very much!

If you donate, please leave a personal address on GitHub, which will be displayed on this page later.

<img src='https://shiyix.cn/images/wx-pay.png' width='200'/>

### Appreciation records

Note: The latest statistical time is 2023/04/08, total amount = 32 yuan

| Nickname | Amount (yuan) | Time | Message | Channel |
|:--:|:--:|:--:|:--:|:--:|
| 普通的disco | 20 | 2023/04/01 | 大佬开源维护不易,加油!希望能有部首查字的功能~ | 微信赞赏码 |
| mango | 5 | 2023/02/10 | - | 微信赞赏码 |
| 阿炜 | 5 | 2022/11/11 | 阿炜ky2700 | 微信赞赏码 |
| slako | 1 | 2022/10/20 | 不明觉厉 | 微信赞赏码 |
| 王三金 | 1 | 2022/10/16 | - | 微信赞赏码 |

---

<details>
Expand Down
19 changes: 19 additions & 0 deletions helper/README.md
Expand Up @@ -42,6 +42,25 @@

[汉字打字游戏](https://theajack.github.io/type/) | [打字弹钢琴](https://theajack.github.io/piano/) | [成语接龙](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/idiom.js) | [通讯录排序](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/sort.js) | [取名字](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/name.js) | [输入法](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/input.js) | [歇后语](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/xhy.js) | [语音识别与合成](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/voice.js) | [简繁体转换](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/trad.js)

### 赞赏

开源维护不易。如果该项目对您有帮助且您有余力,可以微信扫码请作者喝一杯可乐或咖啡,非常感谢!

如捐赠,请备注留一下github个人地址,后续会展示在此页中。

<img src='https://shiyix.cn/images/wx-pay.png' width='200'/>

### 赞赏记录

注:最新统计时间为 2023/04/08,总金额=32元

| 昵称 | 金额(元) | 时间 | 留言 | 渠道 |
|:--:|:--:|:--:|:--:|:--:|
| 普通的disco | 20 | 2023/04/01 | 大佬开源维护不易,加油!希望能有部首查字的功能~ | 微信赞赏码 |
| mango | 5 | 2023/02/10 | - | 微信赞赏码 |
| 阿炜 | 5 | 2022/11/11 | 阿炜ky2700 | 微信赞赏码 |
| slako | 1 | 2022/10/20 | 不明觉厉 | 微信赞赏码 |
| 王三金 | 1 | 2022/10/16 | - | 微信赞赏码 |

---

Expand Down
16 changes: 15 additions & 1 deletion helper/version.md
@@ -1,8 +1,22 @@
## 3.2.4 todo
## TodoList

1. 拼音联想输入法权重调整
2. 语音识别 优化
3. writer 加上canvas渲染
4. 注音支持多音字
5. 新增cnchar-input-ui插件(输入法ui支持)
6. 查询包含某个汉字(笔画序列)的所有汉字【如根据斌字查到赟】
7. 判断某个汉字是否包含某个汉字【如赟字是否包含斌】

## 3.2.4

1. fix: cnchar.spell('洗', 'flat') 参数有bug
2. fix: Cnchar 猫 字默认读音
3. fix: 娘字读音有误
4. fix: 钱字部首查不到,笔、画二字部首有误
5. 增加通过部首查询
6. cnchar-code 增加五笔码
7. 文档首页增加部首展示和五笔展示

## 3.2.3

Expand Down
23 changes: 15 additions & 8 deletions src/cnchar-types/plugin/code/index.d.ts
@@ -1,3 +1,8 @@
/*
* @Author: chenzhongsheng
* @Date: 2022-10-09 09:18:54
* @Description: Coding something
*/
import {Json} from '../../main/common';
import {ICnChar} from '../../main'; // ! important for declare module '../../main/index'

Expand All @@ -13,18 +18,20 @@ export interface ICodeResult extends IDictCodeResult {
unicode: string;
url: string;
gbk: string;
fiveStroke: string;
}
export interface ICode {
(input: string): ICodeResult[];
// 解码时 word传入code 请以空格分割
binary(word: string, decoce?: boolean): string;
char(word: string, decoce?: boolean): string;
unicode(word: string, decoce?: boolean): string;
url(word: string, decoce?: boolean): string;
gbk(word: string, decoce?: boolean): string;
sijiao(word: string, decoce?: boolean): string;
cangjie(word: string, decoce?: boolean): string;
uniform(word: string, decoce?: boolean): string;
binary(word: string, decode?: boolean): string;
char(word: string, decode?: boolean): string;
unicode(word: string, decode?: boolean): string;
url(word: string, decode?: boolean): string;
gbk(word: string, decode?: boolean): string;
sijiao(word: string, decode?: boolean): string;
cangjie(word: string, decode?: boolean): string;
uniform(word: string, decode?: boolean): string;
fiveStroke(word: string, type?: '86'|'98'|'all'): string[];
setCode(words: string | Json<IDictCodeResult>, data?: IDictCodeResult): void;
dict: {code: Json<string>};
}
Expand Down
3 changes: 1 addition & 2 deletions src/cnchar/main/dict/spell-default.json
Expand Up @@ -132,6 +132,5 @@
"蹲": "dūn",
"靚": "liàng",
"刹": "shā",
"彷": "páng",
"风": "fēng"
"彷": "páng"
}
8 changes: 4 additions & 4 deletions src/cnchar/main/dict/spell-dict-jian.json
Expand Up @@ -85,7 +85,7 @@
"chou": "2:丑3仇7抽1俦2帱7臭9惆2绸2畴2愁2稠2筹2酬2瞅3踌2瘳1雠2",
"zhuan": "3:专1传9沌9转9转8砖1啭4赚9撰4篆4颛1馔4",
"zhong": "2:中6中9仲4众4忪6忠1终1肿3盅1种9种8重9钟1冢3舯1衷1锺1踵3螽1塚3",
"feng": "1:丰1凤4风9风8风6冯7讽3沣1奉4枫1封1疯1砜1俸4峰1逢2唪3烽1葑9葑6锋1缝7缝9蜂1酆1峯1",
"feng": "1:丰1凤4风6风9风8冯7讽3沣1奉4枫1封1疯1砜1俸4峰1逢2唪3烽1葑9葑6锋1缝7缝9蜂1酆1峯1",
"dan": "1:丹1旦4石9但4单6担9担6诞4眈1胆3疸8耽1郸1啖4弹9惮9掸8淡4聃1萏4蛋4殚1氮4赕3瘅9瘅6箪1儋9儋6澹9疍4",
"shan": "2:山1讪4闪3汕4删1杉6芟1单9姗1疝4苫9苫6衫1钐9钐6陕3栅6珊1舢1剡9扇9扇6掸9掺8掺6善4禅9跚1骟4煽1鄯4潸1缮4嬗4擅4膳4膻1赡4蟮4鳝4",
"zhi": "2:之1支1止3氏6卮1只8只6汁1执2旨3至4芝1吱6址3志4忮4纸3芷3识9豸4侄2制4帙4帜4枝1治4炙4直2知1祉3织9织6肢1质4郅4咫3峙9指3枳3栀1栉4祗1胝1轵3陟4值2挚4桎4秩4脂1致4贽4轾4埴2掷4痔4窒4职2趾3鸷4彘4智4植2殖7滞4痣4絷2蛭4跖2骘4黹3稚4置4酯3雉4摭2蜘1徵3膣4觯4踬4踯2製4",
Expand Down Expand Up @@ -141,7 +141,7 @@
"zhun": "2:屯6肫1窀1准3谆1",
"hai": "1:亥4还7咳7咳6孩2骇4害9氦4海3胲3嗨6骸2醢3",
"huan": "2:幻4欢1奂4还7环2郇7宦4洹2唤4换4桓2浣4涣4眩9患4焕4萑2逭4痪4缓3豢4漶4锾2鲩4圜7寰2擐4缳2獾1鬟2鹮2嬛2",
"nian": "2:廿4年2念4拈1娘4埝4捻8粘7辇3鲇2蔫1辗8撵3碾3鲶2黏2",
"nian": "2:廿4年2念4拈1埝4捻8粘7辇3鲇2蔫1辗8撵3碾3鲶2黏2",
"kai": "1:开1忾4凯3剀3垲3恺3铠3慨3揩1蒈3锎1楷8锴3闿3",
"xin": "1:心1囟4忻1芯9芯6辛1昕1欣1信4莘6衅4锌1新1歆1薪1镡2馨1鑫1炘1",
"shou": "2:手3守3收1寿4受4狩4首3兽4售4授4绶4瘦4熟7艏3",
Expand All @@ -154,7 +154,7 @@
"ri": "1:日4",
"yue": "2:曰1月4乐9刖4约6岳4哕8栎9说9钥9悦4钺4阅4跃4粤4越4樾4龠4瀹4玥4戉4",
"mu": "1:木4仫4母3目4牟9亩3沐4牡3坶4姆3拇3牧4苜4姥8毪2莫9钼4募4墓4幕4睦4慕4模7暮4穆4",
"mao": "1:毛2卯3矛2峁3泖3牦2茂4茅2茆7茆8冒9昴3贸4旄7旄9耄4铆3猫7猫6袤4帽4瑁4锚2瞀4貌4髦2蝥2懋4蟊2冇3",
"mao": "1:毛2卯3矛2峁3泖3牦2茂4茅2茆7茆8冒9昴3贸4旄7旄9耄4铆3猫6猫7袤4帽4瑁4锚2瞀4貌4髦2蝥2懋4蟊2冇3",
"shui": "3:水3说9谁7税4睡4",
"huo": "2:火3和9或4货4活2钬3获4祸4惑4耠1锪1夥3劐1霍4豁7豁9豁6镬4嚯4攉1藿4蠖4伙3和7和5漷3",
"zhua": "3:爪8抓1挝6",
Expand Down Expand Up @@ -403,7 +403,7 @@
"nuan": "2:暖3",
"miu": "2:谬4缪9",
"seng": "1:僧1",
"niang": "2:酿4孃2嬢2",
"niang": "2:娘2酿4孃2嬢2",
"nou": "1:耨4",
"nang": "1:曩3囊7囊6馕7馕8囔1攮3齉4",
"den": "1:扥4扽4",
Expand Down
2 changes: 1 addition & 1 deletion src/cnchar/main/utils/tool.ts
Expand Up @@ -95,7 +95,7 @@ export function spell (dict: Json<string>, originArgs: Array<string>): string |
} else {
result[i] = item[0];
}
if (has(args, arg.flat)) {
if (has(args, arg.flat) && has(args, arg.tone)) {
result[i] = shapeSpell(result[i], true);
}
}
Expand Down
35 changes: 28 additions & 7 deletions src/cnchar/plugin/code/code.ts
Expand Up @@ -2,7 +2,7 @@
* @Author: tackchen
* @Date: 2022-05-26 09:37:18
* @LastEditors: Please set LastEditors
* @LastEditTime: 2022-06-04 10:04:45
* @LastEditTime: 2023-04-09 11:26:06
* @FilePath: /cnchar/src/cnchar/plugin/code/code.ts
* @Description: Coding something
*/
Expand All @@ -11,7 +11,7 @@ import {ICode, ICodeResult, IDictCodeResult} from 'cnchar-types/plugin/code';
import {Json} from 'cnchar-types/main/common';
import dict from './dict/code.json';
import GBK from './gbk';
import {mapJson} from '@common/util';
import {mapJson, _warn} from '@common/util';

let cnchar: ICnChar;

Expand Down Expand Up @@ -75,6 +75,28 @@ export function uniCode (word: string, decode = false): string {
return decode ? unescape(word) : escape(word);
}

export function fiveStroke (words: string, type: '86'|'98'|'all' = '86') {
if (!cnchar || !cnchar.input) {
_warn('查询五笔输入法需要先安装cnchar和cnchar-input');
return [];
}
const result = [];
for (let i = 0; i < words.length; i++) {
result.push(singleFiveStroke(words[i], type));
}
return result;
}

function singleFiveStroke (word: string, type: '86'|'98'|'all' = '86') {
let code = cnchar.input.dict.wubi[word];
if (!code && cnchar?.hasPlugin('trad')) {
code = cnchar.trad.dict?.wubi[word];
}
if (!code) return '';
if (type === 'all' || code.indexOf(' ') === -1) return code;
return code.split(' ')[type === '86' ? 0 : 1];
}

export const code = ((input: string) => {
const result: ICodeResult[] = [];
for (let i = 0; i < input.length; i++) {
Expand All @@ -87,6 +109,7 @@ export const code = ((input: string) => {
url: urlCode(word),
unicode: uniCode(word),
binary: binaryCode(word),
fiveStroke: singleFiveStroke(word),
});
}
return result;
Expand All @@ -97,11 +120,9 @@ code.char = charCode;
code.gbk = gbkCode;
code.url = urlCode;
code.unicode = uniCode;

code.fiveStroke = fiveStroke;
code.sijiao = buildCommonCode('sijiao');

code.cangjie = buildCommonCode('cangjie');

code.uniform = buildCommonCode('uniform');

code.setCode = (words:string | Json<IDictCodeResult>, data?: IDictCodeResult) => {
Expand Down Expand Up @@ -135,7 +156,7 @@ function parseSingleWordCode (dict: Json<string>, code: string, trad = false): s
}
}

if (!trad && cnchar && cnchar.hasPlugin('trad')) {
if (!trad && cnchar?.hasPlugin('trad')) {
return parseSingleWordCode(cnchar.trad.dict?.code, code, true);
}
return '-';
Expand All @@ -145,7 +166,7 @@ function getSingleWordCode (dict: Json<string>, word: string): IDictCodeResult {
let str = dict[word];

if (!str) {
if (cnchar && cnchar.hasPlugin('trad')) {
if (cnchar?.hasPlugin('trad')) {
str = cnchar.trad.dict?.code?.[word];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cnchar/plugin/info/info.ts
Expand Up @@ -45,7 +45,7 @@ function getSingleWordInfo (dict: Json<string>, word: string): IInfoResult {
let str = dict[word];

if (!str) {
if (cnchar && cnchar.hasPlugin('trad')) {
if (cnchar?.hasPlugin('trad')) {
str = cnchar.trad.dict?.info?.[word];
}
}
Expand Down

0 comments on commit 2d48c24

Please sign in to comment.