{"id":13413568,"url":"https://github.com/mozillazg/go-pinyin","last_synced_at":"2025-05-14T20:02:19.434Z","repository":{"id":23044387,"uuid":"26397419","full_name":"mozillazg/go-pinyin","owner":"mozillazg","description":"汉字转拼音","archived":false,"fork":false,"pushed_at":"2023-07-12T14:32:55.000Z","size":2366,"stargazers_count":1671,"open_issues_count":18,"forks_count":200,"subscribers_count":41,"default_branch":"master","last_synced_at":"2025-04-13T14:00:01.793Z","etag":null,"topics":["chinese","go","golang","hanzi","hanzi-pinyin","pinyin"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/mozillazg/go-pinyin","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/mozillazg.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}},"created_at":"2014-11-09T14:04:33.000Z","updated_at":"2025-04-10T08:37:27.000Z","dependencies_parsed_at":"2024-01-08T15:34:46.699Z","dependency_job_id":null,"html_url":"https://github.com/mozillazg/go-pinyin","commit_stats":{"total_commits":143,"total_committers":7,"mean_commits":"20.428571428571427","dds":0.3776223776223776,"last_synced_commit":"8930bc1fcb5693689dc35d98ad2a4153662e34b1"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Fgo-pinyin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Fgo-pinyin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Fgo-pinyin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Fgo-pinyin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mozillazg","download_url":"https://codeload.github.com/mozillazg/go-pinyin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724585,"owners_count":21151560,"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","hanzi","hanzi-pinyin","pinyin"],"created_at":"2024-07-30T20:01:43.393Z","updated_at":"2025-04-13T14:00:04.304Z","avatar_url":"https://github.com/mozillazg.png","language":"Go","funding_links":[],"categories":["开源类库","Go","Natural Language Processing","Open source library","自然语言处理","Microsoft Office","Bot Building","Relational Databases","Repositories"],"sub_categories":["文本处理","Translation","Word Processing","暂未分类","Strings","翻译","交流","Advanced Console UIs","Uncategorized","暂未分类这些库被放在这里是因为其他类别似乎都不适合。"],"readme":"go-pinyin\n=========\n\n[![Build Status](https://github.com/mozillazg/go-pinyin/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mozillazg/go-pinyin/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/mozillazg/go-pinyin/badge.svg?branch=master)](https://coveralls.io/r/mozillazg/go-pinyin?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mozillazg/go-pinyin)](https://goreportcard.com/report/github.com/mozillazg/go-pinyin)\n[![GoDoc](https://godoc.org/github.com/mozillazg/go-pinyin?status.svg)](https://godoc.org/github.com/mozillazg/go-pinyin)\n\n汉语拼音转换工具 Go 版。\n\n\nInstallation\n------------\n\n```\ngo get github.com/mozillazg/go-pinyin\n```\n\ninstall CLI tool:\n\n```\n# go version\u003e=1.17\ngo install github.com/mozillazg/go-pinyin/cli/pinyin@latest\n\n# go version\u003c1.17\ngo get -u github.com/mozillazg/go-pinyin/cli/pinyin\n\n$ pinyin 中国人\nzhōng guó rén\n```\n\n\nDocumentation\n--------------\n\nAPI documentation can be found here:\nhttps://godoc.org/github.com/mozillazg/go-pinyin\n\n\nUsage\n------\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/mozillazg/go-pinyin\"\n)\n\nfunc main() {\n\thans := \"中国人\"\n\n\t// 默认\n\ta := pinyin.NewArgs()\n\tfmt.Println(pinyin.Pinyin(hans, a))\n\t// [[zhong] [guo] [ren]]\n\n\t// 包含声调\n\ta.Style = pinyin.Tone\n\tfmt.Println(pinyin.Pinyin(hans, a))\n\t// [[zhōng] [guó] [rén]]\n\n\t// 声调用数字表示\n\ta.Style = pinyin.Tone2\n\tfmt.Println(pinyin.Pinyin(hans, a))\n\t// [[zho1ng] [guo2] [re2n]]\n\n\t// 开启多音字模式\n\ta = pinyin.NewArgs()\n\ta.Heteronym = true\n\tfmt.Println(pinyin.Pinyin(hans, a))\n\t// [[zhong zhong] [guo] [ren]]\n\ta.Style = pinyin.Tone2\n\tfmt.Println(pinyin.Pinyin(hans, a))\n\t// [[zho1ng zho4ng] [guo2] [re2n]]\n\n\tfmt.Println(pinyin.LazyPinyin(hans, pinyin.NewArgs()))\n\t// [zhong guo ren]\n\n\tfmt.Println(pinyin.Convert(hans, nil))\n\t// [[zhong] [guo] [ren]]\n\n\tfmt.Println(pinyin.LazyConvert(hans, nil))\n\t// [zhong guo ren]\n}\n```\n\n注意：\n\n* 默认情况下会忽略没有拼音的字符（可以通过自定义 `Fallback` 参数的值来自定义如何处理没有拼音的字符，\n  详见 [示例](https://godoc.org/github.com/mozillazg/go-pinyin#example-Pinyin--FallbackCustom1)）。\n* 根据 [《汉语拼音方案》](http://www.moe.gov.cn/s78/A19/yxs_left/moe_810/s230/195802/t19580201_186000.html) y，w，ü (yu) 都不是声母，\n  以及不是所有拼音都有声母，如果这不是你预期的话，你可能需要的是首字母风格 `FirstLetter`\n  （ [详细信息](https://github.com/mozillazg/python-pinyin#%E4%B8%BA%E4%BB%80%E4%B9%88%E6%B2%A1%E6%9C%89-y-w-yu-%E5%87%A0%E4%B8%AA%E5%A3%B0%E6%AF%8D) ）。\n\n\nRelated Projects\n-----------------\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\npinyin data\n-----------------\n\n* 使用 [pinyin-data](https://github.com/mozillazg/pinyin-data) 的拼音数据\n\n\nLicense\n---------\n\nUnder the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmozillazg%2Fgo-pinyin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmozillazg%2Fgo-pinyin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmozillazg%2Fgo-pinyin/lists"}