|
@@ -5,12 +5,29 @@ import com.aliyun.odps.utils.StringUtils;
|
|
import com.github.houbb.opencc4j.util.ZhConverterUtil;
|
|
import com.github.houbb.opencc4j.util.ZhConverterUtil;
|
|
import com.github.stuxuhai.jpinyin.ChineseHelper;
|
|
import com.github.stuxuhai.jpinyin.ChineseHelper;
|
|
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @author: XuJiakai
|
|
* @author: XuJiakai
|
|
* 2022/3/4 10:31
|
|
* 2022/3/4 10:31
|
|
*/
|
|
*/
|
|
public class FindTraditional2SimpleError extends UDF {
|
|
public class FindTraditional2SimpleError extends UDF {
|
|
- public Boolean evaluate(String val) {
|
|
|
|
|
|
+ public Boolean evaluate(String cname, String historyNames) {
|
|
|
|
+ if (StringUtils.isEmpty(cname) && StringUtils.isEmpty(historyNames)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ if (!compare(cname)) return false;
|
|
|
|
+ if (StringUtils.isEmpty(historyNames)) return true;
|
|
|
|
+ Set<Boolean> set = Arrays.stream(historyNames.split("\t;\t"))
|
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
|
+ .map(String::trim)
|
|
|
|
+ .map(this::compare).collect(Collectors.toSet());
|
|
|
|
+ return !set.contains(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Boolean compare(String val) {
|
|
if (StringUtils.isEmpty(val)) {
|
|
if (StringUtils.isEmpty(val)) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -23,12 +40,13 @@ public class FindTraditional2SimpleError extends UDF {
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
FindTraditional2SimpleError simple = new FindTraditional2SimpleError();
|
|
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("瞭望"));
|
|
|
|
|
|
+ System.out.println(simple.evaluate("深圳市联创银格尔科技有限公司","彙深圳市联创银格尔科技有限公司\t;\t深圳市联创金格尔通讯设备有限公司\t;\t深圳市联创三阳软件有限公司\t;\t"));
|
|
|
|
+ System.out.println(simple.evaluate("滙",null));
|
|
|
|
+ System.out.println(simple.evaluate("匯",null));
|
|
|
|
+ System.out.println(simple.evaluate("彙",null));
|
|
|
|
+ System.out.println(simple.evaluate("恆",null));
|
|
|
|
+ System.out.println(simple.evaluate("文徵明",null));
|
|
|
|
+ System.out.println(simple.evaluate("徵信",null));
|
|
|
|
+ System.out.println(simple.evaluate("瞭望",null));
|
|
}
|
|
}
|
|
}
|
|
}
|