Chineseandpinyin

Java版汉字转拼音工具,支持多样化输出、拼音排序、中英混合排序!Chinese convert to pinyin , Sort by pinyin!

View project onGitHub

chinese To pinyin

Java版汉字转拼音工具,支持多样化输出、拼音排序、中英混合排序!
简易安装指南:


1. 首先: 安装JDK,最好是1.6.0以上;

2. 其次: 直接下载chinesepinyin-V2.0.0.jar并且把'libs'的依赖jar加入到classpath中.

3. 再次:如果想自己自动构建,推荐使用ant. 源代码中已有ant的build.xml文件.

4. 最后:祝你使用愉快,如果发现bug,请联系Dylan.zhangzhi@gmail.com

Basic Introduction:

1. First: install JDK 1.6.* or above

2. Second: Dependence Jar,please see 'libs' folder and add it to your classpath.

3. Third: If you want to build jar by yourself,please install Ant 1.6.* or above first.

4. Last: Welcome to use and report bug, please download it. chinesepinyin-V2.0.0.jar.

代码范例

  
ResourceConfig dHelp = ResourceTool.getInstance();
ResourceTool resourceTool = ResourceTool.getInstance();
Utils utils = Utils.getInstance();

@Test
public void loadResource() {	System.out.println(dHelp.loadResource(ResourceType.LOADPINYINMAP));}
  
/** Output: qíng xù shì tiáo hé liú !  */
System.out.println(resourceTool.findSingtonPinYinByHanZi("情绪是条河流!",ResourceType.OutPutStyle.WITHTONE));

System.out.println(resourceTool.findSingtonPinYinByHanZi("祖國",ResourceType.OutPutStyle.YUNMU)); //Output:  ǔ uó 
  
/** Output: 12345,sha4ng sha1n da3 la3o hu3 ! */
System.out.println(resourceTool.findSingtonPinYinByHanZi("12345,上山打老虎!", ResourceType.OutPutStyle.NUMBER));
  
Comparator comparator = new PinyinComparator();
String[] arr = { "张三", "a","1@","李四","1111111","abc" ,"王二","張三" ,"麻子", "Android", "10086",
				"@%~*&^#$", "hello world", "A","张大","怡情" };
        
List list=Arrays.asList(arr);
Collections.sort(list, comparator);Arrays.sort(arr,comparator);

/** Output: 10086 , 1111111 , 1@ , @%~*&^#$ , A , Android , a , abc , hello world ,  李四 , 麻子 , 王二 , 怡情 , 张大 , 张三 , 張三 ,  */
System.out.println(resourceTool.toStringWith(list," , "));System.out.println(resourceTool.toStringWith(arr," , "));
  
/** Output: kuai */
System.out.println(resourceTool.toPinYinWithStringArray('会',Utils.PinYinStyles.COMPLETE)[1]); 

/** Output: @ */
System.out.println(resourceTool.toPinYinWithString('@',ResourceType.OutPutStyle.WITHTONE,Utils.PinYinStyles.COMPLETE)); 

/** Output: huì */
System.out.println(resourceTool.toPinYinWithString('会',ResourceType.OutPutStyle.WITHTONE,Utils.PinYinStyles.ONLYCHINEASE)); 

/** Output:  */
System.out.println(resourceTool.toPinYinWithString(' ',ResourceType.OutPutStyle.WITHTONE,Utils.PinYinStyles.COMPLETE)); 

/** Output: null */
System.out.println(resourceTool.toPinYinWithString('?',ResourceType.OutPutStyle.WITHTONE,Utils.PinYinStyles.ONLYCHINEASE)); 
  
/** Output: hui   kuai */ 
String[] array = resourceTool.toPinYinWithStringArray('会',Utils.PinYinStyles.ONLYCHINEASE);
for(String temp:array){System.out.print(temp + "   ");}
  

Now I am very happy that release the version 2.0.0; Following is the main function:

1. Get the pinyin of chinese.
2. There are five style about output format.
3. Implement sort by pinyin.
4. More information ,please see "MainTest.java" file.

To-do-list:


1. 实现中文分词.
2. 进一步扩展拼音库.
1. How to Segment the chinese!
2. Extends the chinese dictionary.

If you are instrested in it ,please join us!

There are two branchs "master" and "develop". please clone it . The master is the stable branch; But working on the develop branch.

@author dylan.zhang (Dylan.zhangzhi@gmail.com)