Giter VIP home page Giter VIP logo

pinyin's Introduction

汉字拼音转换工具。


Build Status Coverage Status

转换中文字符为拼音。

注:这是基于浏览器运行的版本,另外还同步提供了更强的 NodeJS 版本


使用说明

var pinyin = require("pinyin");

pinyin("重点");
pinyin("重点", {
  style: pinyin.STYLE_NORMAL,
  heteronym: true
});

API

方法 <Array> pinyin(words[, options])

将传入的中文字符(words)转换成拼音符号。

options 是可选的,可以设定拼音风格,或打开多音字选项。

参数 <Boolean> options.heteronym

是否启用多音字模式,默认关闭。

关闭多音字模式时,返回每个汉字第一个匹配的拼音。

启用多音字模式时,返回多音字的所有拼音列表。

属性 .STYLE_NORMAL

普通风格,即不带音标。

如:pin yin

属性 .STYLE_TONE

声调风格,拼音声调在韵母第一个字母上。

如:pīn yīn

属性 .STYLE_TONE2

声调风格2,即拼音声调在各个拼音之后,用数字 [0-4] 进行表示。

如:pin1 yin1

属性 .STYLE_INITIALS

声母风格,只返回各个拼音的声母部分。

例外,对于只有韵母的汉字(如『爱、啊』等),会先转成不带音标的普通风格。

如:p y

属性 .STYLE_FIRST_LETTER

首字母风格,只返回拼音的首字母部分。

Bitdeli Badge

pinyin's People

Contributors

hotoo avatar bitdeli-chef avatar

Watchers

James Cloos avatar  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.