GithubHelp home page GithubHelp logo

pinyin's Introduction

golang-pinyin

Go语言 中文转拼音类库

安装

go get github.com/gurudin/pinyin

使用


引入

import "github.com/gurudin/pinyin"

转换数组

/* 转换拼音 */
pinyin.Convert("go语言汉字转换拼音")
// -> [go yu yan han zi zhuan huan pin yin]

/* 转换拼音有声调*/
pinyin.UnicodeConvert("go语言汉字转换拼音")
// -> [go yǔ yán hàn zì zhuǎn huàn pīn yīn]

/* 转换拼音数字声调 */
pinyin.ASCIIConvert("go语言汉字转换拼音")
// -> [go yu3 yan2 han4 zi4 zhuan3 huan4 pin1 yin1]

姓名翻译

/* 转换拼音 */
pinyin.Name("冒顿单于").None()
// -> [mo du chan yu]

/* 转换拼音有声调 */
pinyin.Name("冒顿单于").Unicode()
// -> [mò dú chán yú]

/* 转换拼音数字声调 */
pinyin.Name("冒顿单于").ASCII()
// -> [mo4 du2 chan2 yu2]

生成带分隔符的拼音字符串

pinyin.Permalink("go语言汉字转换拼音", "-")
// -> go-yu-yan-han-zi-zhuan-huan-pin-yin

获取首字母带分隔符的拼音字符串

pinyin.Abbr("获取首字母带分隔符的拼音字符串", "")
// -> hqszmdfgfdpyzfc

pinyin.Abbr("获取首字母带分隔符的拼音字符串", "-")
// -> h-q-s-z-m-d-f-g-f-d-p-y-z-f-c

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.