mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix code
This commit is contained in:
parent
96cf2503cc
commit
314cb1b64c
@ -9,4 +9,4 @@
|
||||
* 【all】 升级JDK最低支持到8
|
||||
|
||||
### Bug修复
|
||||
* 【http】 修复Cookie中host失效导致的问题
|
||||
* 【http】 修复Cookie中host失效导致的问题(issue#583@Github)
|
||||
|
@ -160,7 +160,7 @@ public class WordTree extends HashMap<Character, WordTree>{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> findedWords = new ArrayList<String>();
|
||||
List<String> foundWords = new ArrayList<>();
|
||||
WordTree current = this;
|
||||
int length = text.length();
|
||||
//存放查找到的字符缓存。完整出现一个词时加到findedWords中,否则清空
|
||||
@ -187,10 +187,10 @@ public class WordTree extends HashMap<Character, WordTree>{
|
||||
wordBuffer.append(currentChar);
|
||||
if(current.isEnd(currentChar)){
|
||||
//到达单词末尾,关键词成立,从此词的下一个位置开始查找
|
||||
findedWords.add(wordBuffer.toString());
|
||||
if(limit > 0 && findedWords.size() >= limit){
|
||||
foundWords.add(wordBuffer.toString());
|
||||
if(limit > 0 && foundWords.size() >= limit){
|
||||
//超过匹配限制个数,直接返回
|
||||
return findedWords;
|
||||
return foundWords;
|
||||
}
|
||||
if(false == isDensityMatch){
|
||||
//如果非密度匹配,跳过匹配到的词
|
||||
@ -208,7 +208,7 @@ public class WordTree extends HashMap<Character, WordTree>{
|
||||
}
|
||||
current = this;
|
||||
}
|
||||
return findedWords;
|
||||
return foundWords;
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,6 +93,15 @@ public class DfaTest {
|
||||
List<String> all = tree.matchAll("AAAAAAAt-ioBBBBBBB");
|
||||
Assert.assertEquals(all, CollectionUtil.newArrayList("t-io"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aTest(){
|
||||
WordTree tree = new WordTree();
|
||||
tree.addWord("women");
|
||||
String text = "a WOMEN todo.".toLowerCase();
|
||||
List<String> matchAll = tree.matchAll(text, -1, false, false);
|
||||
Assert.assertEquals("[women]", matchAll.toString());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user