代码拉取完成,页面将自动刷新
说太多没用,直接看代码:
@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);
}
这里要说明一下:
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。