/Go-pinyin

hàn zì pīn yīn for Golang

Primary LanguageGoMIT LicenseMIT

Han yu pin yin package for Golang

Get Pinyin Of Simplified Chinese

Install

In you project root path just run go get github.com/struCoder/Go-pinyin

Test

just run go test

How to Use

import (
  "fmt"
  "github.com/struCoder/Go-pinyin"
)

func main() {
  str := "**"
  py := pinyingo.NewPy(pinyingo.STYLE_TONE)       //string with tone        -> **: ["zhōng", "guó"]
  //py := pinyingo.NewPy(pinyingo.STYLE_NORMAL)   //string without tone     -> **: ["zhong", "guo"]
  //py := pinyingo.NewPy(pinyingo.STYLE_INITIALS) // get initials of string -> **: ["zh", "g"]
  fmt.Println(py.Convert(str))
}

Features

  • convert han zi to pinyin
  • get han zi initial
  • deal with heteronym

License

MIT