2021-08-17 10:03:04 索煒達(dá)電子 585
項(xiàng)目編號(hào):E241
文件大?。?51K
源碼說明:帶中文注釋
開發(fā)環(huán)境:GO
簡要概述
gopher們想必都知道,golang關(guān)于都漢語拼音的庫少之又少,Shirdon抽空總結(jié)了漢語拼音包,包含40000多個(gè)字詞,基本覆蓋了漢語的拼音, 喜歡的朋友歡迎star,fork!共同完善!
用法
package main
import (
"fmt"
"gitee.com/shirdonl/pinyin/library"
"regexp"
)
func main() {
dict := library.NewDict()
s := ""
s = dict.Convert(`我,何時(shí)成大牛?`, " ").Unicode()
fmt.Println(s)
s = dict.Sentence(`我,何時(shí)成大牛?`).Unicode()
fmt.Println(s)
// ----
// 轉(zhuǎn)換接口: Dict.Convert
s = dict.Convert(`我愛編程?`, " ").ASCII()
fmt.Println(s)
// 輸入簡體中文, 輸出為帶 連字符- 分隔的拼音字符串
// Unicode 格式顯示
s = dict.Convert(`我,我愛編程?`, "-").Unicode()
fmt.Println(s)
// 轉(zhuǎn)換簡體中文和繁體中文, 轉(zhuǎn)換為帶 斜桿/ 分隔的拼音字符串
// 不顯示聲調(diào)
s = dict.Convert(`我,我愛編程?`, "/").None()
fmt.Println(s)
// 句子接口: Dict.Sentence
// 輸入繁體中文, 輸出為帶 空格 分隔的拼音字符串
// ASCII 格式顯示
s = dict.Sentence(`我,我愛編程?`).ASCII()
fmt.Println(s)
// 輸入簡體中文, 輸出為帶 空格 分隔的拼音字符串
// Unicode 格式顯示
s = dict.Sentence(`我,何時(shí)能暴富?`).Unicode()
fmt.Println(s)
// 轉(zhuǎn)換簡體中文和繁體中文, 轉(zhuǎn)換為帶 空格 分隔的拼音字符
}
文件列表:
目錄│文件列表:
└ pinyin
├ library
│ │ dictionary.go
│ │ dictionary_library.go
│ └ pinyin.go
└ samples
└ main.go