public class WordTree extends HashMap<Character,WordTree>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| 构造器和说明 |
|---|
WordTree()
默认构造
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addWord(String word)
添加单词,使用默认类型
|
void |
addWords(Collection<String> words)
增加一组单词
|
void |
addWords(String... words)
增加一组单词
|
boolean |
isMatch(String text)
指定文本是否包含树中的词
|
String |
match(String text)
获得第一个匹配的关键字
|
List<String> |
matchAll(String text)
找出所有匹配的关键字
|
List<String> |
matchAll(String text,
int limit)
找出所有匹配的关键字
|
List<String> |
matchAll(String text,
int limit,
boolean isDensityMatch,
boolean isGreedMatch)
找出所有匹配的关键字
密集匹配原则:假如关键词有 ab,b,文本是abab,将匹配 [ab,b,ab] 贪婪匹配(最长匹配)原则:假如关键字a,ab,最长匹配将匹配[a, ab] |
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, valuesequals, hashCode, toStringpublic void addWords(Collection<String> words)
words - 单词集合public void addWords(String... words)
words - 单词数组public void addWord(String word)
word - 单词public boolean isMatch(String text)
text - 被检查的文本public List<String> matchAll(String text, int limit)
text - 被检查的文本limit - 限制匹配个数Copyright © 2019. All rights reserved.