{"id":13693677,"url":"https://github.com/go-ego/gpy","last_synced_at":"2025-05-16T12:03:50.527Z","repository":{"id":57481052,"uuid":"95304263","full_name":"go-ego/gpy","owner":"go-ego","description":"Go 语言汉字转拼音工具","archived":false,"fork":false,"pushed_at":"2025-02-12T01:13:36.000Z","size":1158,"stargazers_count":195,"open_issues_count":6,"forks_count":38,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-12T06:13:54.835Z","etag":null,"topics":["chinese","go","golang","pinyin"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/go-ego.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-24T14:56:50.000Z","updated_at":"2025-03-27T10:15:36.000Z","dependencies_parsed_at":"2022-09-26T17:41:27.700Z","dependency_job_id":"6f514430-c971-4d26-8b82-666a72dd4635","html_url":"https://github.com/go-ego/gpy","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-ego%2Fgpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-ego%2Fgpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-ego%2Fgpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-ego%2Fgpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-ego","download_url":"https://codeload.github.com/go-ego/gpy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525138,"owners_count":21118619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chinese","go","golang","pinyin"],"created_at":"2024-08-02T17:01:15.276Z","updated_at":"2025-04-12T06:14:01.122Z","avatar_url":"https://github.com/go-ego.png","language":"Go","funding_links":[],"categories":["开源类库","Open source library"],"sub_categories":["文本处理","Word Processing"],"readme":"# gpy\n\n[![Build Status](https://github.com/go-ego/gpy/workflows/Go/badge.svg)](https://github.com/go-ego/gpy/commits/master)\n[![CircleCI Status](https://circleci.com/gh/go-ego/gpy.svg?style=shield)](https://circleci.com/gh/go-ego/gpy)\n[![Build Status](https://travis-ci.org/go-ego/gpy.svg?branch=master)](https://travis-ci.org/go-ego/gpy)\u003c!-- [![Coverage Status](https://coveralls.io/repos/github.com/go-ego/gpy/badge.svg?branch=master)](https://coveralls.io/r/github.com/go-ego/gpy?branch=master) --\u003e\n[![codecov](https://codecov.io/gh/go-ego/gpy/branch/master/graph/badge.svg)](https://codecov.io/gh/go-ego/gpy)\n[![Go Report Card](https://goreportcard.com/badge/github.com/go-ego/gpy)](https://goreportcard.com/report/github.com/go-ego/gpy)\n[![GoDoc](https://godoc.org/github.com/go-ego/gpy?status.svg)](https://godoc.org/github.com/go-ego/gpy)\n\n汉语拼音转换工具 Go 版。\n\n[简体中文](https://github.com/go-ego/gpy/blob/master/README_zh.md)\n\n\n## Installation\n\n```\ngo get -u github.com/go-ego/gpy\n```\n\n### Install CLI tool:\n\n```\ngo get -u github.com/go-ego/gpy/tools/pinyin\n$ pinyin 中国话\nzhōng guó huà \n\n$ pinyin -s zhao 中国话\nzhong guo hua\n```\n\n## Usage\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/go-ego/gse\"\n\n\t\"github.com/go-ego/gpy\"\n\t\"github.com/go-ego/gpy/phrase\"\n)\n\nvar test = `西雅图都会区; 长夜漫漫, winter is coming!`\n\nfunc main() {\n\targs := gpy.Args{\n\t\tStyle:     gpy.Tone,\n\t\tHeteronym: true}\n\n\tpy := gpy.Pinyin(test, args)\n\tfmt.Println(\"gpy:\", py)\n\n\ts := gpy.ToString(py)\n\tfmt.Println(\"gpy string:\", s)\n\n\tphrase.LoadGseDict()\n\tgo func() {\n\t\tfmt.Println(\"gpy phrase1:\", phrase.Paragraph(test))\n\t}()\n\tfmt.Println(\"gpy phrase2:\", phrase.Paragraph(test))\n\n\tseg := gse.New(\"zh, dict.txt\")\n\t// phrase.DictAdd[\"都会区\"] = \"dū huì qū\"\n\tphrase.AddDict(\"都会区\", \"dū huì qū\")\n\n\tfmt.Println(\"gpy phrase:\", phrase.Paragraph(test, seg))\n\tfmt.Println(\"pinyin: \", phrase.Pinyin(test))\n\tfmt.Println(\"Initial: \", phrase.Initial(\"都会区\"))\n}\n```\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/go-ego/gpy\"\n)\n\nfunc main() {\n\thans := \"中国话\"\n\n\t// 默认\n\ta := gpy.NewArgs()\n\tfmt.Println(gpy.Pinyin(hans, a))\n\t// [[zhong] [guo] [hua]]\n\n\t// 包含声调\n\ta.Style = gpy.Tone\n\tfmt.Println(gpy.Pinyin(hans, a))\n\t// [[zhōng] [guó] [huà]]\n\n\t// 声调用数字表示\n\ta.Style = gpy.Tone2\n\tfmt.Println(gpy.Pinyin(hans, a))\n\t// [[zho1ng] [guo2] [hua4]]\n\n\t// 开启多音字模式\n\ta = gpy.NewArgs()\n\ta.Heteronym = true\n\tfmt.Println(gpy.Pinyin(hans, a))\n\t// [[zhong zhong] [guo] [hua]]\n\ta.Style = gpy.Tone2\n\tfmt.Println(gpy.Pinyin(hans, a))\n\t// [[zho1ng zho4ng] [guo2] [hua4]]\n\n\tfmt.Println(gpy.LazyPinyin(hans, gpy.NewArgs()))\n\t// [zhong guo hua]\n\n\tfmt.Println(gpy.Convert(hans, nil))\n\t// [[zhong] [guo] [hua]]\n\n\tfmt.Println(gpy.LazyConvert(hans, nil))\n\t// [zhong guo hua]\n}\n```\n\n\n## Related Projects\n\n* [hotoo/pinyin](https://github.com/hotoo/pinyin): 汉语拼音转换工具 Node.js/JavaScript 版。\n* [mozillazg/python-pinyin](https://github.com/mozillazg/python-pinyin): 汉语拼音转换工具 Python 版。\n* [mozillazg/rust-pinyin](https://github.com/mozillazg/rust-pinyin): 汉语拼音转换工具 Rust 版。\n\n\n## License\n\nUnder the MIT License, base on [go-pinyin](https://github.com/mozillazg/go-pinyin).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-ego%2Fgpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-ego%2Fgpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-ego%2Fgpy/lists"}