|
@@ -0,0 +1,18 @@
|
|
|
|
+package com.ozs.common.utils;
|
|
|
|
+
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+public class PolyphoneHandler {
|
|
|
|
+ private static final Map<String, String> polyphoneMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ static {
|
|
|
|
+ // 预定义一些多音字的读音
|
|
|
|
+ polyphoneMap.put("长沙", "changsha");
|
|
|
|
+ // 更多的多音字可以在这里添加
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static String getPolyphonePinyin(String chinese) {
|
|
|
|
+ return polyphoneMap.getOrDefault(chinese, ChineseToPingyin.convertHanziToPinyin(chinese));
|
|
|
|
+ }
|
|
|
|
+}
|