pinyin

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: MIT Imports: 6 Imported by: 0

README

Usage

package main

import (
    "fmt"

    pinyin "github.com/pyihe/go-pinyin"
)

func main() {
    adp := pinyin.NewAdapter()
    fmt.Println(adp.ParseHans("我爱中国.", "", pinyin.Normal))           // output: woaizhongguo.
    fmt.Println(adp.ParseHans("我爱中国.", "", pinyin.Tone))             // output: wǒàizhōngguó.
    fmt.Println(adp.ParseHans("我爱中国.", "", pinyin.InitialBigLetter)) // output: WoAiZhongGuo.
}

Documentation

Index

Constants

View Source
const (
	Normal           = 0 // 普通风格:全小写并且不带声调
	Tone             = 1 // 全小写,带声调
	InitialBigLetter = 2 // 首字母大写不带声调
)
View Source
const (
	None = "9999"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

func NewAdapter

func NewAdapter(opts ...Options) *Adapter

func (*Adapter) ParseHans

func (adp *Adapter) ParseHans(hans, split string, yinType Style) string

ParseHans 解析汉字

type Options

type Options func(*Adapter)

func WithTempPath

func WithTempPath(path string) Options

type Style

type Style uint8 // 输出风格

Jump to

Keyboard shortcuts

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