Get Pinyin Of Simplified Chinese
- fix STYLE_FIRST_LETTER
- optimized code
- optimize performance(resolve out of slice len when building)
In you project root path just run go get github.com/struCoder/Go-pinyin
go test
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))
}
- convert han zi to pinyin
- get han zi initial
- deal with segment