GithubHelp home page GithubHelp logo

apple006 / pinyin4js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kaifuny/pinyin4js

0.0 1.0 0.0 447 KB

A opensource javascript library for converting chinese to pinyin

License: MIT License

HTML 0.27% JavaScript 99.73%

pinyin4js's Introduction

[English Document] [中文文档]

pinyin4js

Build Status codebeat badge Downloads Version License

pinyin4js是一个汉字转拼音的Javascript开源库-零依赖
A opensource javascript library for converting chinese to pinyin
Thanks for JPinyin
注:同时支持Node和浏览器使用!!!
Demo Online: https://npm.runkit.com/pinyin4js

Features

  • 零依赖

  • 词库灵活导入,打包
    可以自行调整字典,具体可以参照src/dict;所有资源调用由PinyinResource封装,可自行修改后打包

  • 准确、完善的字库
    Unicode编码从4E00-9FA5范围及3007(〇)的20903个汉字中,pinyin4js能转换除46个异体字(异体字不存在标准拼音)之外的所有汉字

  • 拼音转换速度快
    经测试,从4E00-9FA5范围的20902个汉字,pinyin4js耗时约110毫秒

  • 多拼音格式输出支持
    支持多种拼音输出格式:带音标、不带音标、数字表示音标以及拼音首字母输出格式

  • 常见多音字识别
    支持常见多音字的识别,其中包括词组、成语、地名等

  • 简繁体中文转换

  • 支持添加自定义字典
    支持添加用户自定义字典

How to use

  • INSTALL

Brower

    <script src="./dist/pinyin4js.js"></script>

Node

    npm install pinyin4js
  • USE
    //ES5
    require("pinyin4js"); //import 'pinyin4js';

    // more detail methods in test
    // WITH_TONE_NUMBER--数字代表声调,WITHOUT_TONE--不带声调,WITH_TONE_MARK--带声调

    // output: xià#mén#nǐ#hǎo#dà#shà#xià#mén
    console.log(PinyinHelper.convertToPinyinString('厦门你好大厦厦门', '#', PinyinFormat.WITH_TONE_MARK))

    //首字母风格
    // output: xmnhdsxm
    console.log(PinyinHelper.convertToPinyinString('厦门你好大厦厦门', '', PinyinFormat.FIRST_LETTER))
    // or
    console.log(PinyinHelper.getShortPinyin('厦门你好大厦厦门'))

How to Dev

  • Init
    git clone https://github.com/superbiger/pinyin4js.git
    cd pinyin4js
    npm install
    npm run build
  • Build Browser
    npm run build
    npm run build-browser
  • Test
    npm run test

pinyin4js's People

Contributors

kaifuny avatar

Watchers

 avatar

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.