py

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2022 License: MIT Imports: 4 Imported by: 0

README

go-py

GoCI codecov Go Report Card GoDoc Gitter GitHub license GitHub issues GitHub stars

中文转拼音.

use

go get github.com/xuender/go-py
package main

import (
  "fmt"

  "github.com/xuender/go-py"
  )

func main(){
  fmt.Println(py.Pinyin("阿弥陀佛"))
  fmt.Println(py.Pinyin("阿弥陀佛", py.Tone))
  fmt.Println(py.Pinyin("阿弥陀佛", py.NoTone))
  fmt.Println(py.Pinyin("阿弥陀佛", py.Init))
  fmt.Println(py.Initials("阿弥陀佛"))

  // output:
  // [a1 mi2 tuo2 fu2]
  // [ā mí tuó fú]
  // [a mi tuo fu]
  // [a m t f]
  // amtf
}

cmd

py --help
install
go install github.com/xuender/go-py/cmd/py@latest
examples
py 阿弥陀佛
py -i -s= 阿弥陀佛
py -t -h -hs=\; 阿弥陀佛
py -n 阿弥陀佛

Documentation

Overview

Code generated by dict2data. DO NOT EDIT.

Code generated by dict2data. DO NOT EDIT.

Code generated by dict2data. DO NOT EDIT.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromStyle added in v1.1.2

func FromStyle(pinyin string) string

func Initials

func Initials(str string) string

func IsHan

func IsHan(han rune) bool

func Pinyin

func Pinyin(str string, options ...Option) []string
Example
fmt.Println(py.Pinyin("特长"))
fmt.Println(py.Pinyin("长相"))

fmt.Println(py.Pinyin("阿弥陀佛"))
fmt.Println(py.Pinyin("阿弥陀佛", py.Tone))
fmt.Println(py.Pinyin("阿弥陀佛", py.NoTone))
fmt.Println(py.Pinyin("阿弥陀佛", py.Init))
fmt.Println(py.Initials("阿弥陀佛"))
Output:

[te4 cha2ng]
[zha3ng xia1ng]
[a1 mi2 tuo2 fu2]
[ā mí tuó fú]
[a mi tuo fu]
[a m t f]
amtf

func Pinyins

func Pinyins(str string, options ...Option) [][]string

func Py

func Py(str, sep string, options ...Option) string

func RuneOption added in v1.1.2

func RuneOption(han rune, option Option, index int, runes []rune) []string

func Style

func Style(pinyin string, option Option) string

func ToPolyphonic added in v1.1.2

func ToPolyphonic(tones []string, han rune, index int, runes []rune) []string

func ToStrings added in v1.1.2

func ToStrings(pinyin []uint16, option Option) []string

func ToneIndex added in v1.1.2

func ToneIndex(tone string) int

Types

type Option

type Option int
const (
	Normal Option = iota
	Tone
	NoTone
	Init
)

type Polyphonic added in v1.1.2

type Polyphonic struct {
	Tone  uint8
	Words []string
}

Directories

Path Synopsis
cmd
py
tools

Jump to

Keyboard shortcuts

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