|
@@ -1,14 +1,14 @@
|
|
package com.lantone.qc.kernel.util;
|
|
package com.lantone.qc.kernel.util;
|
|
|
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import com.lantone.qc.kernel.catalogue.QCCatalogue;
|
|
import com.lantone.qc.kernel.catalogue.QCCatalogue;
|
|
-import com.lantone.qc.pub.model.InputInfo;
|
|
|
|
|
|
+import com.lantone.qc.pub.util.ListUtil;
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
import lombok.Getter;
|
|
import lombok.Getter;
|
|
import lombok.Setter;
|
|
import lombok.Setter;
|
|
-import org.springframework.core.annotation.Order;
|
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
@@ -28,8 +28,9 @@ public class CatalogueUtil {
|
|
public static boolean isEmpty(String content) {
|
|
public static boolean isEmpty(String content) {
|
|
return StringUtil.isBlank(removeSpecialChar(content));
|
|
return StringUtil.isBlank(removeSpecialChar(content));
|
|
}
|
|
}
|
|
|
|
+
|
|
public static String removeSpecialChar(String content) {
|
|
public static String removeSpecialChar(String content) {
|
|
- if (StringUtil.isEmpty(content)){
|
|
|
|
|
|
+ if (StringUtil.isEmpty(content)) {
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
return content.replaceAll("[\r\n|/r/n|\n|/n|/t|\t]", "").trim();
|
|
return content.replaceAll("[\r\n|/r/n|\n|/n|/t|\t]", "").trim();
|
|
@@ -53,4 +54,36 @@ public class CatalogueUtil {
|
|
}
|
|
}
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * words中的所有词,哪些不包含在text文本里的引号下面
|
|
|
|
+ * 如:
|
|
|
|
+ * word:{"高血压","糖尿病","白血病","感冒"}
|
|
|
|
+ * text: 否认患有"高血压,糖尿病等","白血病",感冒
|
|
|
|
+ * 结果:感冒
|
|
|
|
+ *
|
|
|
|
+ * @param words
|
|
|
|
+ * @param text
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public static List<String> noInQuotes(List<String> words, String text) {
|
|
|
|
+ List<String> retWords = Lists.newArrayList();
|
|
|
|
+ if (ListUtil.isNotEmpty(words) && StringUtil.isNotBlank(text)) {
|
|
|
|
+ List<String> sections = Lists.newArrayList();
|
|
|
|
+ int index = 0;
|
|
|
|
+ for (String txt : text.split("\"")) {
|
|
|
|
+ if (index % 2 == 1) {
|
|
|
|
+ sections.add(txt);
|
|
|
|
+ }
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+ for (String word : words) {
|
|
|
|
+ if (StringUtil.isNotBlank(word) && sections.stream().filter(section -> section.indexOf(word) != -1).count() == 0) {
|
|
|
|
+ retWords.add(word);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return retWords;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|