Browse Source

REPORT-11692 alphafine分词查询结果中包含了连词结果

代码质量
master
alex.sung 6 years ago
parent
commit
d891df9538
  1. 6
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  2. 22
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java

6
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java

@ -141,9 +141,9 @@ public class AlphaFineConstants {
public static final String BACK_ICON_NAME = "back@1x.png";
public static final ArrayList<String> CONJUNCTION = new ArrayList<String>() {{
add("和");
add("与");
add("的");
add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_HE"));
add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_YU"));
add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_DE"));
}};
}

22
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java

@ -6,7 +6,6 @@ import com.fr.stable.StringUtils;
import com.fr.third.ibm.icu.text.BreakIterator;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -73,30 +72,13 @@ public class SegmentationManager {
int start = itor.first();
for (int end = itor.next(); end != BreakIterator.DONE; start = end, end = itor.next()) {
String temp = searchText.substring(start, end);
if (!StringUtils.isEmpty(temp)) {
//去掉空和连词
if (!StringUtils.isEmpty(temp) & !AlphaFineConstants.CONJUNCTION.contains(temp)) {
result.add(temp);
}
}
result = removeConjunction(result);
String[] strings = new String[result.size()];
result.toArray(strings);
return strings;
}
/**
* 去除连词
*
* @param result
* @return
*/
public static List<String> removeConjunction(List<String> result) {
Iterator<String> it = result.iterator();
while (it.hasNext()) {
String s = it.next();
if (AlphaFineConstants.CONJUNCTION.contains(s)) {
it.remove();
}
}
return result;
}
}

Loading…
Cancel
Save