Esempio n. 1
0
 /** 获取所有的停止词 */
 public Set<String> allStopwords() {
   Node<Void> root = stopWords.getRoot();
   final List<Character> list = new ArrayList<>();
   root.childHandle(
       new NodeChildHandle<Void>() {
         @Override
         public boolean onHandle(Node<Void> child) {
           list.add(child.getChar());
           return true;
         }
       });
   Set<String> allStopWords = new HashSet<>();
   for (Character c : list) {
     List<Map.Entry<String, Void>> ret = stopWords.prefixSearch(c.toString());
     if (ret != null) {
       for (Map.Entry<String, Void> e : ret) {
         allStopWords.add(e.getKey());
       }
     }
   }
   return allStopWords;
 }
Esempio n. 2
0
 /** 判断是否为停止词 */
 public static boolean isStopword(char[] text, int off, int len) {
   Node node = INSTANCE.getInstance().stopWords.getNode(text, off, len);
   return node != null && node.accept();
 }