一、自定义
1、splitWords
private static void splitWords(String source, Map<String, Object> wordMap){
StringBuilder sb = new StringBuilder();
for(int i = 0; i < source.length(); i++) {
char c = source.charAt(i);
switch(c) {
case ' ':
case '/':
case '|':
case '\\':
case ',':
case ';':
case ',':
case ';':
case '.':
case '。':
case ':':
case ':':
case '_':
case '-':
case '—':
case '?':
case '!':
case '!':
case '&':
if(sb.length() > 0) {
wordMap.put(sb.toString(), "Y");
sb.setLength(0);
}
break;
default:
sb.append(c);
break;
}
}
if(sb.length() > 0) {
wordMap.put(sb.toString(), "Y");
}
}