{"id":13626045,"url":"https://github.com/flyerhzm/chinese_pinyin","last_synced_at":"2025-04-08T09:13:33.365Z","repository":{"id":835782,"uuid":"555970","full_name":"flyerhzm/chinese_pinyin","owner":"flyerhzm","description":"translate chinese hanzi to pinyin","archived":false,"fork":false,"pushed_at":"2021-04-18T23:30:38.000Z","size":287,"stargazers_count":429,"open_issues_count":10,"forks_count":58,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-01T08:39:53.607Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/flyerhzm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-03-10T14:19:59.000Z","updated_at":"2025-01-19T12:48:26.000Z","dependencies_parsed_at":"2022-08-16T11:05:19.336Z","dependency_job_id":null,"html_url":"https://github.com/flyerhzm/chinese_pinyin","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/flyerhzm%2Fchinese_pinyin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyerhzm%2Fchinese_pinyin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyerhzm%2Fchinese_pinyin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyerhzm%2Fchinese_pinyin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flyerhzm","download_url":"https://codeload.github.com/flyerhzm/chinese_pinyin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247809964,"owners_count":20999816,"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":[],"created_at":"2024-08-01T21:02:08.560Z","updated_at":"2025-04-08T09:13:33.323Z","avatar_url":"https://github.com/flyerhzm.png","language":"Ruby","funding_links":[],"categories":["Libraries/Packages","Ruby"],"sub_categories":["Ruby"],"readme":"# ChinesePinyin\n\n[![Chinese Pinyin](https://github.com/flyerhzm/chinese_pinyin/actions/workflows/chinese_pinyin.yml/badge.svg)](https://github.com/flyerhzm/chinese_pinyin/actions/workflows/chinese_pinyin.yml)\n\nTranslate chinese hanzi to pinyin.\n\nThe dict is borrowed from \u003chttp://github.com/fayland/perl-lingua-han/tree/master/Lingua-Han-PinYin/\u003e\n\n## Install\n\n```\ngem install chinese_pinyin\n```\n\nor add in Gemfile.\n\n```\ngem 'chinese_pinyin'\n```\n\n## Usage\n\nBy CLI\n\n\n```\n$ ch2py -h\nUsage: ch2py [opts]\n    -c, --camelcase                  Camelcase of each word\n    -i, --stdin                      Read from stdard input\n    -t, --tone                       Show tone at end of word\n    -m, --tonemarks                  Show tone at top of letter, this\nwould cover -t option\n    -s, --splitter \u003csplitter\u003e        Splitter of each word, use a space\nby default\n    -v, --version                    Show version\n    -h, --help                       Show this help\n\n$ ch2py 中文\nzhong wen\n```\n\nBy code\n\n```\nrequire 'chinese_pinyin'\n\nPinyin.t('中国')  =\u003e \"zhong guo\"\nPinyin.t('你好world') =\u003e \"ni hao world\"\nPinyin.t('中国', splitter: '-') =\u003e \"zhong-guo\"\nPinyin.t('中国', splitter: '') =\u003e \"zhongguo\"\nPinyin.t('中国', tone: true) =\u003e \"zhong1 guo2\"\nPinyin.t('中国', tonemarks: true) =\u003e \"zhōng guó\"\nPinyin.t('北京') { |letters| letters[0].upcase } =\u003e 'BJ'\nPinyin.t('北京') { |letters, i| letters[0].upcase if i == 0 } =\u003e 'B'\n```\n\n## Polyphone Issue\n\nuse Words.dat to override default behavior.\n\nby default\n\n```\nPinyin.t('广州') =\u003e \"yan zhou\"\n```\n\nadd file Words.dat\n\n```\n广州|guang3 zhou1\n```\n\nset `ENV['WORDS_FILE']` for Words.dat\n\n```\nENV['WORDS_FILE'] = \"Words.dat path\"\nPinyin.t('广州') =\u003e \"guang zhou\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyerhzm%2Fchinese_pinyin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflyerhzm%2Fchinese_pinyin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyerhzm%2Fchinese_pinyin/lists"}