pinyingo

package module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2017 License: MIT Imports: 8 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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 :)

pay to me

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	STYLE_NORMAL       = 1
	STYLE_TONE         = 2
	STYLE_INITIALS     = 3
	STYLE_FIRST_LETTER = 4
	USE_SEGMENT        = true
	NO_SEGMENT         = false

	DICT_DIR     = path.Join(os.Getenv("GOPATH"), "src/github.com/struCoder/Go-pinyin/dict")
	DICT_PHRASES = path.Join(DICT_DIR, "phrases-dict")
)
View Source
var INITIALS []string = strings.Split("b,p,m,f,d,t,n,l,g,k,h,j,q,x,r,zh,ch,sh,z,c,s", ",")

Functions

func NewPy

func NewPy(style int, segment bool) *options

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址