pinyin

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package pinyin the chinese pinyin.

Index

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

func GetLinesFromByte(content []byte) []string

GetLinesFromByte the line byte

func GetLinesFromFile

func GetLinesFromFile(filename string) []string

GetLinesFromFile the line from file

func IsChineseCharacters

func IsChineseCharacters(word string) bool

IsChineseCharacters check if the string is chinese character

func ReadDickFromByteKv

func ReadDickFromByteKv(content []byte) map[string]string

ReadDickFromByteKv read file and parse from ini files

func ReadDickFromIni

func ReadDickFromIni(filename string) map[string]map[string]string

ReadDickFromIni read file and parse from ini files

func ReadIniLines

func ReadIniLines(lines []string) map[string]map[string]string

ReadIniLines read ini file as line array, support [key], and repeat parse line.

Types

type Pinyin

type Pinyin struct {
	Dicks map[string]map[string]string
	// contains filtered or unexported fields
}

Pinyin the pinyin dick creator

func NewPinyin

func NewPinyin(filename string) *Pinyin
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) GetPyTone

func (pyt *Pinyin) GetPyTone(chinese string) string

GetPyTone get pinyin with tone

func (*Pinyin) GetPyToneAlpha

func (pyt *Pinyin) GetPyToneAlpha(chinese string) string

GetPyToneAlpha get pinyin without tone

func (*Pinyin) GetPyToneFunc

func (pyt *Pinyin) GetPyToneFunc(chinese string, call func(string) string) string

GetPyToneFunc get pinyin with tone by callback Func

func (*Pinyin) GetPyToneNumber

func (pyt *Pinyin) GetPyToneNumber(chinese string) string

GetPyToneNumber get pinyin with tone that replace by number (1-4)

func (*Pinyin) LineToDick

func (pyt *Pinyin) LineToDick(lines []string) *Pinyin

LineToDick turn lines to dick data.

Directories

Path Synopsis
Package material the Material of pinyin dick, it's `embed`.
Package material the Material of pinyin dick, it's `embed`.

Jump to

Keyboard shortcuts

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