Browse Source

fix: 修复繁体转简体问题

许家凯 3 years ago
parent
commit
83e3fa6f2f
2 changed files with 13 additions and 8 deletions
  1. 10 4
      pom.xml
  2. 3 4
      src/main/scala/com/winhc/bigdata/spark/utils/CompanyIndexUtils.scala

+ 10 - 4
pom.xml

@@ -359,11 +359,17 @@
             <artifactId>guava</artifactId>
             <version>23.0</version>
         </dependency>
-        <!-- https://mvnrepository.com/artifact/com.github.stuxuhai/jpinyin -->
+<!--        &lt;!&ndash; https://mvnrepository.com/artifact/com.github.stuxuhai/jpinyin &ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>com.github.stuxuhai</groupId>-->
+<!--            <artifactId>jpinyin</artifactId>-->
+<!--            <version>1.1.8</version>-->
+<!--        </dependency>-->
+
         <dependency>
-            <groupId>com.github.stuxuhai</groupId>
-            <artifactId>jpinyin</artifactId>
-            <version>1.1.8</version>
+            <groupId>com.github.houbb</groupId>
+            <artifactId>opencc4j</artifactId>
+            <version>1.7.2</version>
         </dependency>
 
 

+ 3 - 4
src/main/scala/com/winhc/bigdata/spark/utils/CompanyIndexUtils.scala

@@ -1,6 +1,6 @@
 package com.winhc.bigdata.spark.utils
 
-import com.github.stuxuhai.jpinyin.ChineseHelper
+import com.github.houbb.opencc4j.util.ZhConverterUtil
 import com.winhc.bigdata.spark.implicits.CaseClass2JsonHelper._
 import com.winhc.bigdata.spark.utils.BaseUtil.cleanup
 import org.apache.commons.lang3.StringUtils
@@ -118,14 +118,13 @@ object CompanyIndexUtils {
 
   def convertToSimplifiedChinese(name: String): String = {
     if (StringUtils.isEmpty(name)) null
-    else ChineseHelper.convertToSimplifiedChinese(name)
+    else ZhConverterUtil.toSimple(name)
   }
 
 
   def main(args: Array[String]): Unit = {
     //    println(company_score_weight("存续(在营、开业、在册)","新疆现代特油科技股份有限公司","200309577000000","1"))
-
-    println(getCompanyName("香港中旅(中國)國際投資有限公司").buildJson)
+    println(getCompanyName("滙").buildJson)
   }
 
 }