Documentation ¶
Overview ¶
Package pinyin the chinese pinyin.
Index ¶
- Variables
- func GetLinesFromByte(content []byte) []string
- func GetLinesFromFile(filename string) []string
- func IsChineseCharacters(word string) bool
- func ReadDickFromByteKv(content []byte) map[string]string
- func ReadDickFromIni(filename string) map[string]map[string]string
- func ReadIniLines(lines []string) map[string]map[string]string
- type Pinyin
- func (pyt *Pinyin) GetPyTone(chinese string) string
- func (pyt *Pinyin) GetPyToneAlpha(chinese string) string
- func (pyt *Pinyin) GetPyToneFunc(chinese string, call func(string) string) string
- func (pyt *Pinyin) GetPyToneNumber(chinese string) string
- func (pyt *Pinyin) LineToDick(lines []string) *Pinyin
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( CcReg = regexp.MustCompile("^[\u4E00-\u9FA5]$") ChineseToneMap = map[string]map[string]int{ "ue": map[string]int{ "üē": 1, "üé": 2, "üě": 3, "üè": 4, }, "a": map[string]int{ "ā": 1, "á": 2, "ǎ": 3, "à": 4, }, "e": map[string]int{ "ē": 1, "é": 2, "ě": 3, "è": 4, }, "i": map[string]int{ "ī": 1, "í": 2, "ǐ": 3, "ì": 4, }, "o": map[string]int{ "ō": 1, "ó": 2, "ǒ": 3, "ò": 4, }, "u": map[string]int{ "ū": 1, "ú": 2, "ǔ": 3, "ù": 4, }, } )
Functions ¶
func GetLinesFromByte ¶
GetLinesFromByte the line byte
func GetLinesFromFile ¶
GetLinesFromFile the line from file
func IsChineseCharacters ¶
IsChineseCharacters check if the string is chinese character
func ReadDickFromByteKv ¶
ReadDickFromByteKv read file and parse from ini files
func ReadDickFromIni ¶
ReadDickFromIni read file and parse from ini files
Types ¶
type Pinyin ¶
Pinyin the pinyin dick creator
func NewPinyin ¶
Example ¶
var filename, pinyin string // filename is pinyin dick file or use `pinyin/material` for builtin. py := NewPinyin(filename) pinyin = py.GetPyToneAlpha(`古丞秋`) fmt.Println(pinyin) pinyin = py.GetPyTone(`中华人民共和国`) fmt.Println(pinyin)
Output: gu cheng qiu zhōng huá rén mín gòng hé guó
func (*Pinyin) GetPyToneAlpha ¶
GetPyToneAlpha get pinyin without tone
func (*Pinyin) GetPyToneFunc ¶
GetPyToneFunc get pinyin with tone by callback Func
func (*Pinyin) GetPyToneNumber ¶
GetPyToneNumber get pinyin with tone that replace by number (1-4)
func (*Pinyin) LineToDick ¶
LineToDick turn lines to dick data.
Click to show internal directories.
Click to hide internal directories.