Coder Social home page Coder Social logo

theajack / cnchar Goto Github PK

View Code? Open in Web Editor NEW
2.3K 28.0 244.0 37.13 MB

🇨🇳 功能全面的汉字工具库 (拼音 笔画 偏旁 成语 语音 可视化等) (Chinese character util)

Home Page: https://theajack.github.io/cnchar

License: MIT License

JavaScript 5.80% Vue 6.47% Stylus 0.13% CSS 4.45% TypeScript 83.04% Shell 0.12%
spell-stroke draw chinese-characters pinyin speak voice-recognition

cnchar's Introduction

cnchar's People

Contributors

dependabot[bot] avatar givebest avatar koumaza avatar mapull avatar theajack avatar theajack3 avatar yingshike avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cnchar's Issues

typescript 引入报错

node_modules/[email protected]@cnchar-draw/index.d.ts:4:19 - error TS1183: An implementation cannot be declared in ambient contexts.

4     constructor() {};
                    ~

node_modules/[email protected]@cnchar-draw/index.d.ts:74:2 - error TS1036: Statements are not allowed in ambient contexts.

74 };
    ~

啥情况?
typescript 3.7.4

繁體 鐘 字無法找到.

因為要計算姓 鐘 的有多少筆畫, 發現沒有鐘字, 請問可否添加到繁體庫中呢. 因為百家姓裡 也有這個字

“南”字拼音不对

“南”给出的拼音是Na,跃然“南”字在“南无阿弥陀佛”里面读na,但一般用法还是读nan的多

Wrong spelling in cnchar-poly

画栋朝飞南浦云,珠帘暮卷西山雨
huà dòng cháo fēi nā pǔ yún , zhū lián mù juàn xī shān yù.

The third character's spelling must be 'zhāo', and the eleventh character's spelling must be 'juǎn'

JS.ORG CLEANUP

JS.ORG CLEANUP

Hello, it seems a js.org subdomain that was requested to target this repository no longer works.
The subdomain requested was cnchar.js.org and had the target of theajack.github.io/cnchar.
It produced the following failures when tested as part of the cleanup:

  • HTTP: Failed with status code '404 Not Found'
  • HTTPS: Failed with status code '404 Not Found'

To keep the js.org subdomain you should add a page with reasonable content within a month so the subdomain passes the validation.
Failure to rectify the issues will result in the requested subdomain being removed from JS.ORGs DNS and the list of active subdomains.

If you are wanting to keep the js.org subdomain and have added reasonable content, YOU MUST reply to the main cleanup issue with the response format detailed at the top to keep the requested subdomain.

🤖 Beep boop. I am a robot and performed this action automatically as part of the js.org cleanup process. If you have an issue, please contact the js.org maintainers.

.net 版本

请问什么时候会考虑出.net版本的?

未收录拼音 den

cnchar.spellToWord('den') // 错误的拼音: den
且不支持api设置:
cnchar.setSpell('扥', 'den4')

打包后的资源存在ES6语法?

{t=r.initial[n],o=e.spell.substr(t.length);break}return{spell:e.spell,tone:e.tone,index:e.index,initial:t,final:o}};const u=(n,e,t)=>{if("object"!=typeof n)t(n,e);else for(const e in n)t(e,n[e])},c=n=>{const e=n.charCodeAt(0);return e>=19968&&e<=40869},p=(n,e)=>-1!==n.indexOf(e);const f=n=>{console.warn("CnChar Warning:"+n)};var h=t(3);const d=h,g="āáǎàōóǒòēéěèīíǐìūúǔùǖǘǚǜńňǹ",y={array:"array",low:"low",up:"up",first:"first",poly:"poly",tone:"tone",simple:"simple",trad:"trad"};let m;function x(n,e){const t=e[0].split(""),o=e.splice(1);("spell",o);const r=p(o,y.poly),i=p(o,y.tone),a=[];for(const e in n){const o=n[e],s=parseInt(o[0]);for(let n=0;n<t.length;n++){const l=t[n];if(c(l)){let u=o.indexOf(l);if(-1!==u){const c=C(e,o,u,r,i,s);if(c.poly){a[n]||(a[n]=[]),a[n].push(c.res);let t=o;const p=t.match(new RegExp(l,"g")).length;for(let o=1;o<p;o++)t=t.substr(u+2),u=t.indexOf(l),a[n].push(C(e,t,u,r,i,s).res)}else c.isPolyWord&&d[l]&&(c.res=O(d[l],i).spell),a[n]=[c.res],t[n]=""}}else""!==l&&(a[n]=["NOT_CNCHAR",l])}}k(a,o);const s=[];for(let n=0;n<t.length;n++){const e=a[n];void 0===e?s[n]=t[n]:e.length>1?"NOT_CNCHAR"===e[0]?s[n]=e[1]:s[n]=(${a[n].join("|")}):s[n]=e[0]}return p(o,y.array)?s:s.join("")}const k=(n,e)=>{m..poly&&w(n,T),p(e,y.first)&&w(n,b),p(e,y.up)?w(n,z):p(e,y.low)||w(n,j)};function w(n,e){n.forEach((t,o)=>{"string"!=typeof t?"NOT_CNCHAR"!==t[0]&&t.forEach((n,o)=>{t[o]=e(n)}):n[o]=e(t)})}function b(n){return n[0]}function z(n){return n.toUpperCase()}function j(n){return z(n[0])+n.substr(1)}function T(n){return n.toLowerCase()}function C(n,e,t,o,r,i){let a=parseInt(e[t+1]);const s={res:n,poly:!1,isPolyWord:a>=5};return o||r?(s.isPolyWord&&(a-=5,o&&(s.poly=!0)),r&&(s.res=S(n,i,a)),s):s}const O=(n,e)=>{if(e)return{spell:n};for(let e=0;e<n.length;e++){const t=g.indexOf(n[e]);if(-1!==t)return{spell:n.substr(0,e)+"aoeiuün"[Math.floor(t/4)]+n.substr(e+1),tone:t%4+1,index:e+1}}return{spell:n,tone:0,index:-1}};function S(n,e,t){if(0===t)return n;const o=n[e],r=g[4"aoeiuün".indexOf(o)+(t-1)];return o!==r?n.replace(o,r):n}function v(n,e){const t=e[0].split(""),o=[],r=e.splice(1);_("stroke",r);for(const e in n)for(let r=0;r<t.length;r++)t[r]&&-1!==n[e].indexOf(t[r])&&(t[r]="",o[r]=parseInt(e));return t.forEach((n,e)=>{n&&(o[e]=0)}),p(r,y.array)?o:W(o)}const W=n=>{let e=0;return n.forEach((function(n){e+=n})),e};let q=!1;const _=(n,e,t)=>{if(!m.check)return;if(q)return void(q=!1);t&&(q=!0);const o=[];for(let t=e.length-1;t>=0;t--){const r=e[t];m.type[n][r]||(o.push(r),e.splice(t,1))}const r=[],i=[],a=(n,t=r)=>{n instanceof Array?n.forEach(n=>{a(n,t)}):p(e,n)&&t.push(n)};-1===m.plugins.indexOf("trad")&&(p(e,"simple")&&r.push("simple"),p(e,"trad")&&r.push("trad")),"spell"===n?

const =>箭头函数

偏旁部首错误问题

半:不是 丶?
眝:不是 目?
冒:不是 冃?
耄耋:不是老?
有很多字的偏旁都有问题...

红色

红色 翻译成Gong Se了

不准确的多音字

**银行行长

pinyin with tone: Zhōng,Guó,Yín,Háng,*Xíng,Cháng

行长

pinyin with tone: *Xíng,Cháng

spell-dic-jian 说明

在 spell-dic-jian.json 文件里

"hei": "1:黑1嗨6嘿6",
"ng": "0:嗯9嗯7嗯8",

像上面这样的是什么意思,作者能说明一下吗?

hei 是读音能看懂,1: 是什么意思,还有这个 嗯9嗯7嗯8 为啥要这样写?

因为在使用的时候,发现很多音问题,特别是多音字的默认音。因此打算研究一下代码。

将军 :qiāngjūn
是否:shìpǐ
长不大:chángbùdà
单于:chányú (这个是对的)

cnchar 当前最新版,参数 spell('low','tone')

There is an unexpected result for Chinese character `任`.

Hi, this project brings a lot of help for Chinese projects, great!
Now there is a bug report.


The detail

Whatever the word is 任何 or 任意, its tone is always Rén(wrong) rather than Rèn(right).
In fact, as we known, Rén is just used for surname or name of place, such as 任长霞, 河北任丘.

image

Best Regards.

“啊”的变调读法

“啊”的变调读法有六种,具体如下:
1、前一个的韵尾是“a、o、e、i、u、ü”时,读成“ia”。
2、前一个的韵尾是“u、ao、ou”时,读成“ua”。
3、前一个的韵尾是“n”时,读成“na”。
4、前一个的韵尾是“ng”时,读成“nga”。
5、前面音节是zhi、chi、shi、ri “啊”读作“ra”。例如:“快吃啊!”
6、前面音节是zi、ci、si时,“啊”读作“za”例如:“这东西真次啊!”
感谢您的开源,cnchar太实用了。
我的微信-16608921567,QQ-88190168。

nodejs下stroke参数无效

var cnchar = require('cnchar');
var poly = require('cnchar-poly');
var order = require('cnchar-order');
var trad = require('cnchar-trad');
// var draw = require('cnchar-draw');

// console.log('汉字'.spell())
console.log('张三'.stroke('order', 'detail'))

CnChar Warning:以下参数无效:["detail","order"]; 可选值:[array]

笔顺绘制模式的画布大小会受其他模式的干扰

笔顺绘制模式type: cnchar.draw.TYPE.STROKE和其他模式一起使用的时候,比如和测验模式type: cnchar.draw.TYPE.TEST一起使用的时候,笔顺绘制模式的svg宽度会受到测验模式的影响。
比如笔顺绘制时我定义length为80,测验模式时为120,则笔顺绘制的笔顺大小为80,但svg画布宽度会变成120。
这是什么原因呢?
image

笼罩

发音应该是
[拼音] | [lǒng zhào]

但是这里是Lóng Zhào 。

cnchar.draw能否提供一个接口返回svg数据?

这样子就可以在微信小程序中,通过把svg转base64的方式来显示了。

只是提个建议,目前其实并没有这样的需求,只是觉得如果有这样的接口会很棒,当然现在也很棒,非常感谢作者的开发能有这么棒的一个开源项目~

typescript import error

The index.d.ts syntax error: A rest parameter cannot be optional.ts(1047)

spell(sentence: string, ...args?: Array<spellArg>): string | Array<any>;
stroke(sentence: string, ...args?: Array<strokeArg>): number | Array<any>;
use(...plugins: Array<Function>): void;
spellToWord(spell: string, ...args?: Array<spellToWordArg>): string | Array<string>;
strokeToWord(stroke: number, ...args?: Array<strokeToWordArg>): string | Array<string>;

sortSpell(spells:Array<string> | string, ...args?: Array<'tone'|'desc'>): Array<string> | string;

宝盖头第二笔是啥?

cnchar.stroke('宝', 'order', 'name'),输出点,撇点,横撇|横钩,横,横,竖,横,点,第二笔是撇点
cnchar.stroke('宝', 'order', 'shape'),输出丶,㇀,㇇|乛,一,一,丨,一,丶,第二笔是
可是cnchar.orderToWord.orders里面的撇点对应的是𡿨
cnchar.orderToWord(['点', '撇点', '横钩'], 'start'),不能输出宝盖头的字。

所以宝盖头第二笔是啥?

使用HanziWriter中的某些字调用stroke('order','name')方法后得到undefined

成功个数 8075 失败汉字如下 [
'⺀', '⺈', '⺊', '⺌', '⺍', '⺗', '⺮', '⺳', '⺼', '㐆',
'㐌', '㐬', '㐭', '㐱', '㒸', '㒼', '㓞', '㔾', '㕡', '㝵',
'㠯', '㡭', '㢆', '㢟', '㣎', '㥯', '㧜', '㬎', '㲋', '㳄',
'㼌', '㿽', '䍃', '䕭', '䙴', '䜌', '䠀', '䧹', '䰾', '䴉',
'丂', '丄', '丏', '丨', '丩', '丬', '丱', '丵', '丶', '丷',
'丿', '乑', '乚', '乛', '乶', '乹', '乿', '亅', '亙', '亠',
'亶', '亹', '亼', '亾', '仌', '伄', '伕', '伾', '佇', '佉',
'併', '佽', '侌', '侷', '係', '俉', '俛', '倀', '倖', '倝',
'倞', '倠', '倻', '偽', '傕', '傖', '傚', '傢', '傯', '傿',
'僂', '僉', '僕', '僱', '儂', '儅', '儕', '儘', '儷', '儸',
... 1399 more items
] 一共失败 1499 个。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.