{"id":37029574,"url":"https://github.com/frapples/java-pinyin","last_synced_at":"2026-01-14T03:33:45.066Z","repository":{"id":57733245,"uuid":"149003331","full_name":"frapples/java-pinyin","owner":"frapples","description":"A library that provides Pinyin and Chinese conversion and Chinese word segmentation.一个汉字与拼音互转的工具库，提供简单的分词功能。","archived":false,"fork":false,"pushed_at":"2023-05-23T20:10:54.000Z","size":58,"stargazers_count":23,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-01T04:10:24.745Z","etag":null,"topics":["chinese","hans","java","java-pinyin","pinyin"],"latest_commit_sha":null,"homepage":"","language":"Java","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/frapples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-16T14:26:23.000Z","updated_at":"2024-12-26T06:57:08.000Z","dependencies_parsed_at":"2022-09-26T22:11:19.725Z","dependency_job_id":null,"html_url":"https://github.com/frapples/java-pinyin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/frapples/java-pinyin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frapples%2Fjava-pinyin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frapples%2Fjava-pinyin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frapples%2Fjava-pinyin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frapples%2Fjava-pinyin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frapples","download_url":"https://codeload.github.com/frapples/java-pinyin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frapples%2Fjava-pinyin/sbom","scorecard":{"id":409882,"data":{"date":"2025-08-11","repo":{"name":"github.com/frapples/java-pinyin","commit":"1d62f94f69f9ac3231111211ce389107b94c2892"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 1/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":6,"reason":"4 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-5mg8-w23w-74h3","Warn: Project is vulnerable to: GHSA-7g45-4rm6-3mm3","Warn: Project is vulnerable to: GHSA-mvr2-9pj6-7w5j","Warn: Project is vulnerable to: GHSA-6phf-6h5g-97j2"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T22:25:11.395Z","repository_id":57733245,"created_at":"2025-08-18T22:25:11.395Z","updated_at":"2025-08-18T22:25:11.395Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","hans","java","java-pinyin","pinyin"],"created_at":"2026-01-14T03:33:44.510Z","updated_at":"2026-01-14T03:33:45.055Z","avatar_url":"https://github.com/frapples.png","language":"Java","funding_links":[],"categories":["人工智能"],"sub_categories":["自然语言处理"],"readme":"# 介绍及特性\n这个项目的缘起是，前几天女朋友问我有没有java的拼音转汉字的库，一查似乎没有，于是找到python-pinyin，剽窃之。 :joy: 哈哈。\n\n将汉字转拼音，或者是将拼音转汉字的一个工具库，内存占用很小。功能有：\n\n1. 支持中文词汇、中文单词转拼音。\n2. 支持词汇拼音、单子拼音转中文。\n3. 支持音调，可支持不同风格的输出。\n4. 支持语句或文章转拼音，使用分词算法解决多音字问题。\n5. 词库借用python-pinyin词库，非常丰富。\n6. 支持中文分词。\n\n关于词库，实际上还是比python-pinyin少了不少。\n这是因为java作为历史悠久的语言，char是双字节，无法表示所有的unicode字符。\n目前暂时不考虑超过双字节编码的汉字，之后再查找资料完善。\n\n但是，双字节编码的已有汉字已经非常够用了，被排除在外的几乎都是十分生僻的汉字了。\n\n后续完善：\n1. [x] 分词算法支持的句子转拼音。\n2. [ ] 更多分词算法。\n2. [ ] 根据拼音序列，智能匹配，转句子。\n5. [ ] 可扩展词库。\n4. [ ] LRU Cache，可选策略。\n5. [ ] 尝试优化Sqlite查询性能。\n6. [ ] 尝试提供一个可选功能，用户可启动通过预加载常用数据到内存的方式提升性能。（场景如服务器端程序）\n3. [ ] 性能测试。\n\n# 安装及环境要求\njdk版本要求：jdk \u003e= 1.6\n\nmaven配置，pom.xml中添加：\n```xml\n\u003cdependencies\u003e\n  \u003cdependency\u003e\n    \u003cgroupId\u003eio.github.frapples.javapinyin\u003c/groupId\u003e\n    \u003cartifactId\u003ejava-pinyin\u003c/artifactId\u003e\n    \u003cversion\u003e1.0-alpha-1\u003c/version\u003e\n  \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n由于附带词库的原因，因此这个包可能有点大。有可能网络问题出现下载不全的情况，清掉maven缓存再reimport下。\n\n# 使用例子\n## 单字或词语转换\n词语转拼音，支持多种输出风格：\n```java\nList\u003cString\u003e result = JavaPinyin.pinyinForWord(\"一举两得\");\n// [yī, jǔ, liǎng, dé]\n\nList\u003cString\u003e result = JavaPinyin.pinyinForWord(\"一举两得\",Style.TONE2);\n// [yi1, ju3, lia3ng, de2]\n\nList\u003cString\u003e result = JavaPinyin.pinyinForWord(\"一举两得\",Style.TONE3);\n// [yi1, ju3, liang3, de2]\n\nList\u003cString\u003e result = JavaPinyin.pinyinForWord(\"一举两得\",Style.NORMAL);\n// [yi, ju, liang, de]\n```\n单字转拼音，返回所有多音字拼音：\n```java\n List\u003cString\u003e result = JavaPinyin.pinyinForHans('中');\n // [zhōng, zhòng]\n List\u003cString\u003e result = JavaPinyin.pinyinForHans('中', Style.TONE3);\n // [zhong1, zhong4]\n```\n\n单个拼音转汉字，返回所有的同音字：\n```java\nList\u003cCharacter\u003e result = JavaPinyin.pinyinToHans(\"a\");\n// [吖, 呵, 呵, 呵, 呵, 啊, 啊, 啊, 啊, 啊, 嗄, 嗄, 腌, 錒, 锕, 阿, 阿, 阿, 阿]\n```\n\n词汇拼音转中文，返回所有的同音词：\n```java\nList\u003cString\u003e result = JavaPinyin.pinyinToWord(Arrays.asList(\"zhong\", \"dian\"));\n// [中点, 重典, 重点]\n```\n\n## 句子转换\n\n句子转拼音，智能解决多音字问题：\n```java\nList\u003cList\u003cString\u003e\u003e result = JavaPinyin.pinyin(\"中文自动分词指的是使用计算机自动对中文文本进行词语的切分\");\n// [[zhōng], [wén], [zì], [dòng], [fēn], [cí], [zhǐ], [de], [shì], [shǐ], [yòng], [jì], [suàn], [jī], [zì], [dòng], [duì], [zhōng], [wén], [wén], [běn], [jìn], [xíng], [cí], [yǔ], [de], [qiē], [fēn]]\n```\n\n## 分词\n简单分词：\n```java\nList\u003cString\u003e result = JavaPinyin.segment(\"中文自动分词指的是使用计算机自动对中文文本进行词语的切分\");\n// [中文, 自动, 分词, 指的, 是, 使用, 计算机, 自动, 对, 中文, 文本, 进行, 词语, 的切, 分]\n```\n支持选择分词算法，参见该函数的重载版本。不过目前分词算法只有最大正向匹配一种。。。\n\n# 资源消耗\n1. 内存占用方面：非常小。\n2. 性能方面：第一次调用需要耗费点时间，后面调用就快。目前没有严谨的beanchmark。\n\n# 感谢\n本项目主要参考及借用了以下项目的词库，表示感谢：\n1. https://github.com/mozillazg/python-pinyin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrapples%2Fjava-pinyin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrapples%2Fjava-pinyin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrapples%2Fjava-pinyin/lists"}