All Projects → go-ego → Gpy

go-ego / Gpy

Licence: apache-2.0
Go 语言汉字转拼音工具

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Gpy

pinyin data
🐼 Easy to use and portable pronunciation data for Hanzi characters.
Stars: ✭ 13 (-90.44%)
Mutual labels:  pinyin, chinese
rust-pinyin
汉字转拼音
Stars: ✭ 111 (-18.38%)
Mutual labels:  pinyin, chinese
chinese-rhymer
轻量中文押韵神器,100%绝对可用,傻瓜式命令行操作,秒速实现烈焰单押,闪电双押,龙卷三押以及海啸式四押,目前版本 v0.2.6。Search for rhymes for Chinese words, with 1, 2, 3 and 4 characters, released on PyPI with current version of 0.2.6.
Stars: ✭ 72 (-47.06%)
Mutual labels:  pinyin, chinese
pinyin4js
A opensource javascript library for converting chinese to pinyin。welcome Star : P
Stars: ✭ 153 (+12.5%)
Mutual labels:  pinyin, chinese
Xpinyin
Translate Chinese hanzi to pinyin (拼音) by Python, 汉字转拼音
Stars: ✭ 709 (+421.32%)
Mutual labels:  chinese, pinyin
hanzi-pinyin-font
Chinese font displaying Hanzi (汉字) characters with by transliteration/pronunciation (Pīnyīn).
Stars: ✭ 79 (-41.91%)
Mutual labels:  pinyin, chinese
syng
A free, open source, cross-platform, Chinese-To-English dictionary for desktops.
Stars: ✭ 108 (-20.59%)
Mutual labels:  pinyin, chinese
Somiao Pinyin
Somiao Pinyin: Train your own Chinese Input Method with Seq2seq Model 搜喵拼音输入法
Stars: ✭ 209 (+53.68%)
Mutual labels:  chinese, pinyin
Pinyin
🇨🇳 汉字拼音 ➜ hàn zì pīn yīn
Stars: ✭ 6,047 (+4346.32%)
Mutual labels:  chinese, pinyin
Chineseutil
PHP 中文工具包,支持汉字转拼音、拼音分词、简繁互转、数字、金额大写;QQ群:17916227
Stars: ✭ 413 (+203.68%)
Mutual labels:  chinese, pinyin
Python Pinyin
汉字转拼音(pypinyin)
Stars: ✭ 3,618 (+2560.29%)
Mutual labels:  chinese, pinyin
Go Pinyin
汉字转拼音
Stars: ✭ 907 (+566.91%)
Mutual labels:  chinese, pinyin
Hanbaobao
Mandarin Chinese text segmentation and mobile dictionary Android app (中文分词)
Stars: ✭ 17 (-87.5%)
Mutual labels:  chinese, pinyin
Cn sort
中文排序:按拼音/笔顺快速排序简体中文词组(百万数量级,可含中英/多音字)。如果对您有所帮助,欢迎点个star鼓励一下。
Stars: ✭ 102 (-25%)
Mutual labels:  chinese, pinyin
Data
中国政治和社会事件时间线数据仓库 Database for the timeline of political and societal events in China
Stars: ✭ 117 (-13.97%)
Mutual labels:  chinese
The Road To Learn React Chinese
《React 学习之道》The Road to learn React (简体中文版) | 最简单,且最实用的 React 实战教程。
Stars: ✭ 1,631 (+1099.26%)
Mutual labels:  chinese
Blog
部署在 GitBook 上的个人博客。
Stars: ✭ 112 (-17.65%)
Mutual labels:  chinese
Docs Cn
OpenTelemetry Markdown中文文档: 接入使用、技术标准、RFC、SDK等. 中文网站:https://ot.md
Stars: ✭ 109 (-19.85%)
Mutual labels:  chinese
Ehviewer
前任作者NekoInverter在gitlab重新更新EhViewer了,我不再独立维护项目,本项目暂时封存。 请前往 https://gitlab.com/NekoInverter/EhViewer 获取最新版本。
Stars: ✭ 127 (-6.62%)
Mutual labels:  chinese
Awesome Chinese Podcasts
一些不错的中文podcasts
Stars: ✭ 124 (-8.82%)
Mutual labels:  chinese

gpy

CircleCI Status Build Status codecov Go Report Card GoDoc

汉语拼音转换工具 Go 版。

简体中文

Installation

go get -u github.com/go-ego/gpy

install CLI tool:

go get -u github.com/go-ego/gpy/tools/pinyin
$ pinyin 中国话
zhōng guó huà 

$ pinyin -s zhao 中国话
zhong guo hua

Documentation

API documentation can be found here: godoc

Usage

package main

import (
	"fmt"

	"github.com/go-ego/gse"

	"github.com/go-ego/gpy"
	"github.com/go-ego/gpy/phrase"
)

var test = `西雅图都会区; 长夜漫漫, winter is coming!`

func main() {
	args := gpy.Args{
		Style:     gpy.Tone,
		Heteronym: true}

	py := gpy.Pinyin(test, args)
	fmt.Println("gpy:", py)

	s := gpy.ToString(py)
	fmt.Println("gpy string:", s)

	phrase.LoadGseDict()
	go func() {
		fmt.Println("gpy phrase1:", phrase.Paragraph(test))
	}()
	fmt.Println("gpy phrase2:", phrase.Paragraph(test))

	seg := gse.New("zh, dict.txt")
	// phrase.DictAdd["都会区"] = "dū huì qū"
	phrase.AddDict("都会区", "dū huì qū")

	fmt.Println("gpy phrase:", phrase.Paragraph(test, seg))
	fmt.Println("pinyin: ", phrase.Pinyin(test))
	fmt.Println("Initial: ", phrase.Initial("都会区"))
}
package main

import (
	"fmt"

	"github.com/go-ego/gpy"
)

func main() {
	hans := "中国话"

	// 默认
	a := gpy.NewArgs()
	fmt.Println(gpy.Pinyin(hans, a))
	// [[zhong] [guo] [hua]]

	// 包含声调
	a.Style = gpy.Tone
	fmt.Println(gpy.Pinyin(hans, a))
	// [[zhōng] [guó] [huà]]

	// 声调用数字表示
	a.Style = gpy.Tone2
	fmt.Println(gpy.Pinyin(hans, a))
	// [[zho1ng] [guo2] [hua4]]

	// 开启多音字模式
	a = gpy.NewArgs()
	a.Heteronym = true
	fmt.Println(gpy.Pinyin(hans, a))
	// [[zhong zhong] [guo] [hua]]
	a.Style = gpy.Tone2
	fmt.Println(gpy.Pinyin(hans, a))
	// [[zho1ng zho4ng] [guo2] [hua4]]

	fmt.Println(gpy.LazyPinyin(hans, gpy.NewArgs()))
	// [zhong guo hua]

	fmt.Println(gpy.Convert(hans, nil))
	// [[zhong] [guo] [hua]]

	fmt.Println(gpy.LazyConvert(hans, nil))
	// [zhong guo hua]
}

Related Projects

License

Under the MIT License, base on go-pinyin.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].