|
@@ -0,0 +1,34 @@
|
|
|
+package com.winhc.bigdata.udf.string;
|
|
|
+
|
|
|
+import com.aliyun.odps.udf.UDF;
|
|
|
+import com.aliyun.odps.utils.StringUtils;
|
|
|
+import com.github.houbb.opencc4j.util.ZhConverterUtil;
|
|
|
+import com.github.stuxuhai.jpinyin.ChineseHelper;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author: XuJiakai
|
|
|
+ * 2022/3/4 10:31
|
|
|
+ */
|
|
|
+public class FindTraditional2SimpleError extends UDF {
|
|
|
+ public Boolean evaluate(String val) {
|
|
|
+ if (StringUtils.isEmpty(val)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ String oldVal = ChineseHelper.convertToSimplifiedChinese(val);
|
|
|
+ String newVal = ZhConverterUtil.toSimple(val);
|
|
|
+ return oldVal.equals(newVal);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ FindTraditional2SimpleError simple = new FindTraditional2SimpleError();
|
|
|
+ System.out.println(simple.evaluate("滙"));
|
|
|
+ System.out.println(simple.evaluate("匯"));
|
|
|
+ System.out.println(simple.evaluate("彙"));
|
|
|
+ System.out.println(simple.evaluate("恆"));
|
|
|
+ System.out.println(simple.evaluate("文徵明"));
|
|
|
+ System.out.println(simple.evaluate("徵信"));
|
|
|
+ System.out.println(simple.evaluate("瞭望"));
|
|
|
+ }
|
|
|
+}
|