| 
					
				 | 
			
			
				@ -7,7 +7,6 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.util.Assert; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -20,6 +19,12 @@ public class PinYinUtils { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public static final Map<String, String> multiToneMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					static { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						multiToneMap.put("重庆", "C"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						multiToneMap.put("广东", "G"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						multiToneMap.put("广西", "G"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 //将中文转换为英文 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public static String getEname(String name) throws  Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -83,7 +88,7 @@ public class PinYinUtils { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								String[] temp = PinyinHelper.toHanyuPinyinStringArray(arr[0], defaultFormat); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 长度大于1,表明是多音字,往后多取一个字或两个字,取词组,取匹配多音字属性文件确定最终读音 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (temp != null && temp.length > 1 && !temp[0].equalsIgnoreCase(temp[1])) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									String finalLetter = chinese; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									String finalLetter = getOrgNameMultiTone(chinese); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									if(StringUtils.isEmpty(finalLetter)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										System.out.print(arr[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										System.out.print(arr[1]+":["); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -113,19 +118,22 @@ public class PinYinUtils { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public static String getOrgNameMultiTone(String chinesePhrase) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						Assert.notNull(chinesePhrase, "中文词组不可为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if (multiToneMap.containsKey(chinesePhrase.substring(0, 1))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return multiToneMap.get(chinesePhrase.substring(0, 1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} else if (multiToneMap.containsKey(chinesePhrase.substring(0, 2))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return multiToneMap.get(chinesePhrase.substring(0, 2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} else if (multiToneMap.containsKey(chinesePhrase.substring(0, 3))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return multiToneMap.get(chinesePhrase.substring(0, 3)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (multiToneMap.containsKey(chinesePhrase.substring(0, 1))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return multiToneMap.get(chinesePhrase.substring(0, 1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} else if (multiToneMap.containsKey(chinesePhrase.substring(0, 2))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return multiToneMap.get(chinesePhrase.substring(0, 2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} else if (multiToneMap.containsKey(chinesePhrase.substring(0, 3))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return multiToneMap.get(chinesePhrase.substring(0, 3)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						}catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public static void main(String[] args)  throws  Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						System.out.println(getUpEname("李宇春")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						System.out.println(getFirstSpell("广西")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |