pinyin

package
v0.0.0-...-2d91a95 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version   = "0.2.1"
	Author    = "mozillazg, 闲耘"
	License   = "MIT"
	Copyright = "Copyright (c) 2014 mozillazg, 闲耘"
)

Meta

View Source
const (
	Normal      = 0 // Normal style, without tones (default style). Such as: pin yin
	Tone        = 1 // tone style 1, phonetic tone in the first letter of the vowel. Such as: pīn yīn
	Tone2       = 2 // tone style 2, that is, phonetic tone after each pinyin, with the number [0-4] said. Such as: pi1n yi1n
	Initials    = 3 // initials style, only return the initial part of each pinyin. Such as: Chinese Pinyin zh g
	FirstLetter = 4 // The first letter style, only the first letter part of the phonetic alphabet. Such as: p y
	Finals      = 5 // Vowel style 1, only return the vowel part of each pinyin, without tones. Such as: ong uo
	FinalsTone  = 6 // Vowel style 2, with tone, tone in the first letter of the finals. Such as: ōng uó
	FinalsTone2 = 7 // Vowel style 2, with tone, tone after each pinyin, with the number [0-4] said. Such as: o1ng uo2
)

Pinyin style (recommended)

View Source
const (
	NORMAL       = 0 // Normal style, without tones (default style). Such as: pin yin
	TONE         = 1 // tone style 1, phonetic tone in the first letter of the vowel. Such as: pīn yīn
	TONE2        = 2 // tone style 2, that is, phonetic tone after each pinyin, with the number [0-4] said. Such as: pi1n yi1n
	INITIALS     = 3 // initials style, only return the initial part of each pinyin. Such as: Chinese Pinyin zh g
	FIRST_LETTER = 4 // The first letter style, only the first letter part of the phonetic alphabet. Such as: p y
	FINALS       = 5 // Vowel style 1, only return the vowel part of each pinyin, without tones. Such as: ong uo
	FINALS_TONE  = 6 // Vowel style 2, with tone, tone in the first letter of the finals. Such as: ōng uó
	FINALS_TONE2 = 7 // Vowel style 2, with tone, tone after each pinyin, with the number [0-4] said. Such as: o1ng uo2
)

Pinyin style (compatible with previous versions)

Variables

View Source
var Heteronym = false

default configuration: whether to enable polyphonic mode

View Source
var PinyinDict = map[int]string{}/* 42013 elements not displayed */

拼音库,抓取自汉典网(zdic.net)。包含下列范围的 Unicode 字符:

CJK基本:[4E00-9FFF]       CJK扩展A:[3400-4DBF]
CJK扩展B:[20000-2A6DF]    CJK扩展C:[2A700-2B73F]
CJK扩展D:[2B740-2B81D]    CJK兼容扩展:[2F800-2FA1F]
CJK部首扩展:[2E80-2EFF]   CJK笔画:[31C0-31EF]
CJK康熙部首:[2F00-2FDF]   CJK兼容:[F900-FAFF]

注释掉了没有拼音的字符。

View Source
var Separator = "-"

default configuration: `Slug` join in the use of the separator

View Source
var Style = Normal

default configuration: style

Functions

func LazyPinyin

func LazyPinyin(s string, a Args) []string

LazyPinyin Chinese characters to Pinyin, and `Pinyin` difference is: return value type is different, and does not support multi-tone mode, each Chinese word only take the first sound.

func Pinyin

func Pinyin(s string, a Args) [][]string

Pinyin Chinese characters to Pinyin, support multi-tone mode.

func SinglePinyin

func SinglePinyin(r rune, a Args) []string

SinglePinyin converts a single `rune` type of Chinese characters into pinyin.

func Slug

func Slug(s string, a Args) string

Slug join `LazyPinyin` 's return value.

func SortInitials

func SortInitials(strs []string)

按首字母排序

Types

type Args

type Args struct {
	Style     int    // Pinyin style (default: Normal)
	Heteronym bool   // enable polyphonic mode (default: disabled)
	Separator string // the delimiter used in Slug (default :-)
}

Args configuration information

func NewArgs

func NewArgs() Args

NewArgs returns `Args` containing the default configuration

Jump to

Keyboard shortcuts

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