Browse Source

代码质量

final/10.0
alex.sung 6 years ago
parent
commit
dc4894321f
  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

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

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