1 Star 0 Fork 0

iameven / PyinConventor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

这是一个工具包,用于汉字与拼音的互转。

说太多没用,直接看代码:

@Test
public void test() throws IOException {

    //拼音数据源
    File root = new File(ClassLoader.getSystemResource("").getFile());
    InputStream in = new FileInputStream(new File(root, "pinyin.properties"));
    PyinDataSource source = new PropertiesPyinDataSource(in);

    //分词器
    Segmentationer segmentationer = new IKSegmentationer();

    String result = PyinConventor.create(source, segmentationer, "金石为开").withToneMark().generatePinyin();

    assertEquals("jīnshíwèikāi", result);
}

这里要说明一下:

  • 拼音数据源:目前负责将传入的汉字转成拼音,而源可以有很多种:从数据库里读,从properties里读,你可以根据自己的需要进行实现。
  • 分词器:汉字有很多多音字,在不同的词里,会有不同的音,所以需要分词后,再查那个汉字的拼音。 Segmentationer也是一个接口而已。本库中默认使用IKAnalyzer分词系统。 由于IKAnalyzer没有放在maven中央仓储,所以需要加到本地中:

mvn install:install-file -Dfile=ikanalyzer jar包路径 -DgroupId=org.wltea.ik-analyzer -DartifactId=ik-analyzer -Dversion=3.2.8 -Dpackaging=jar

空文件

简介

用于将汉字转成拼音的工具包:支持多种数据源,简单的API 展开 收起
Java
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/xuyifei/pyinconventor.git
git@gitee.com:xuyifei/pyinconventor.git
xuyifei
pyinconventor
PyinConventor
master

搜索帮助