Skip to content
hàn zì pīn yīn for Golang
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dict
.gitignore
LICENSE
README.md
convert.go
pinyingo_test.go
tools.go
zi.go

README.md

Han yu pin yin package for Golang

Get Pinyin Of Simplified Chinese

Change log

2017-04-24

  1. fix STYLE_FIRST_LETTER

2016-06-21

  1. optimized code

2016-03-18

  1. optimize performance(resolve out of slice len when building)

Install

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

Test

go test

How to Use

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

func main() {
  str := "中国"
  str1 := "重阳"
  py := pinyingo.NewPy(pinyingo.STYLE_TONE, pinyingo.NO_SEGMENT)       //string with tone        -> 中国: ["zhōng", "guó"]
  //py := pinyingo.NewPy(pinyingo.STYLE_NORMAL, pinyingo.NO_SEGMENT)   //string without tone     -> 中国: ["zhong", "guo"]
  //py := pinyingo.NewPy(pinyingo.STYLE_INITIALS, pinyingo.NO_SEGMENT) // get initials of string -> 中国: ["zh", "g"]

  //segment
  py := pinyingo.NewPy(pinyingo.STYLE_TONE, pinyingo.USE_SEGMENT)       //string with tone        -> 重阳: ["chóng", "yáng"]

  fmt.Println(py.Convert(str))
}

Features

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

support this project :)

Paypal Alipay
paypal alipay

License

MIT

You can’t perform that action at this time.