Skip to content

Commit 26c40fb

Browse files
committed
fix stopchars
1 parent 6b843b1 commit 26c40fb

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

hutool-dfa/src/main/java/cn/hutool/dfa/StopChar.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
package cn.hutool.dfa;
22

3-
import java.util.Set;
4-
53
import cn.hutool.core.collection.CollUtil;
64

5+
import java.util.Set;
6+
77
/**
88
* 过滤词及一些简单处理
9-
*
9+
*
1010
* @author Looly
1111
*/
1212
public class StopChar {
1313
/** 不需要处理的词,如标点符号、空格等 */
1414
public static final Set<Character> STOP_WORD = CollUtil.newHashSet(' ', '\'', '、', '。', //
15-
'·', 'ˉ', 'ˇ', '々', '—', '~', '‖', '…', '‘', '’', '“', '”', '〔', '〕', '〈', '〉', '《', '》', '「', '」', '『', //
16-
'』', '〖', '〗', '【', '】', '±', '+', '-', '×', '÷', '∧', '∨', '∑', '∏', '∪', '∩', '∈', '√', '⊥', '⊙', '∫', //
17-
'∮', '≡', '≌', '≈', '∽', '∝', '≠', '≮', '≯', '≤', '≥', '∞', '∶', '∵', '∴', '∷', '♂', '♀', '°', '′', '〃', //
18-
'℃', '$', '¤', '¢', '£', '‰', '§', '☆', '★', '〇', '○', '●', '◎', '◇', '◆', '□', '■', '△', '▽', '⊿', '▲', //
19-
'▼', '◣', '◤', '◢', '◥', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█', '▉', '▊', '▋', '▌', '▍', '▎', '▏', '▓', //
20-
'※', '→', '←', '↑', '↓', '↖', '↗', '↘', '↙', '〓', 'ⅰ', 'ⅱ', 'ⅲ', 'ⅳ', 'ⅴ', 'ⅵ', 'ⅶ', 'ⅷ', 'ⅸ', 'ⅹ', '①', //
21-
'②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩', '⒈', '⒉', '⒊', '⒋', '⒌', '⒍', '⒎', '⒏', '⒐', '⒑', '⒒', '⒓', //
22-
'⒔', '⒕', '⒖', '⒗', '⒘', '⒙', '⒚', '⒛', '⑴', '⑵', '⑶', '⑷', '⑸', '⑹', '⑺', '⑻', '⑼', '⑽', '⑾', '⑿', '⒀', //
23-
'⒁', '⒂', '⒃', '⒄', '⒅', '⒆', '⒇', 'Ⅰ', 'Ⅱ', 'Ⅲ', 'Ⅳ', 'Ⅴ', 'Ⅵ', 'Ⅶ', 'Ⅷ', 'Ⅸ', 'Ⅹ', 'Ⅺ', 'Ⅻ', '!', //
24-
'#', '¥', '%', '&', '(', ')', '*', ',', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', //
25-
'8', '9', ':', ';', '<', '=', '>', '?', '@', '\', '^', '_', '{', '|', '}', 'Ρ', //
26-
'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', //
27-
'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω', '﹊', '﹍', '╭', '╮', '╰', '╯', '', '_', //
28-
'/', '\\', '\"', '<', '>', '`', '{', '}', '~', '(', ')', '-', //
29-
'$', '@', '*', '&', '#', '卐', '㎎', '㎏', '㎜', '㎝', '㎞', '㎡', '㏄', '㏎', '㏑', '㏒', '㏕', '+', '=', '?',
30-
':', '.', '!', ';', ']','|','%');
15+
'·', 'ˉ', 'ˇ', '々', '—', '~', '‖', '…', '‘', '’', '“', '”', '〔', '〕', '〈', '〉', '《', '》', '「', '」', '『', //
16+
'』', '〖', '〗', '【', '】', '±', '+', '-', '×', '÷', '∧', '∨', '∑', '∏', '∪', '∩', '∈', '√', '⊥', '⊙', '∫', //
17+
'∮', '≡', '≌', '≈', '∽', '∝', '≠', '≮', '≯', '≤', '≥', '∞', '∶', '∵', '∴', '∷', '♂', '♀', '°', '′', '〃', //
18+
'℃', '$', '¤', '¢', '£', '‰', '§', '☆', '★', '〇', '○', '●', '◎', '◇', '◆', '□', '■', '△', '▽', '⊿', '▲', //
19+
'▼', '◣', '◤', '◢', '◥', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█', '▉', '▊', '▋', '▌', '▍', '▎', '▏', '▓', //
20+
'※', '→', '←', '↑', '↓', '↖', '↗', '↘', '↙', '〓', 'ⅰ', 'ⅱ', 'ⅲ', 'ⅳ', 'ⅴ', 'ⅵ', 'ⅶ', 'ⅷ', 'ⅸ', 'ⅹ', '①', //
21+
'②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩', '⒈', '⒉', '⒊', '⒋', '⒌', '⒍', '⒎', '⒏', '⒐', '⒑', '⒒', '⒓', //
22+
'⒔', '⒕', '⒖', '⒗', '⒘', '⒙', '⒚', '⒛', '⑴', '⑵', '⑶', '⑷', '⑸', '⑹', '⑺', '⑻', '⑼', '⑽', '⑾', '⑿', '⒀', //
23+
'⒁', '⒂', '⒃', '⒄', '⒅', '⒆', '⒇', 'Ⅰ', 'Ⅱ', 'Ⅲ', 'Ⅳ', 'Ⅴ', 'Ⅵ', 'Ⅶ', 'Ⅷ', 'Ⅸ', 'Ⅹ', 'Ⅺ', 'Ⅻ', '!', //
24+
'#', '¥', '%', '&', '(', ')', '*', ',', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', //
25+
'8', '9', ':', ';', '<', '=', '>', '?', '@', '〔', '\', '〕', '^', '_', '‘', '{', '|', '}', 'Ρ', //
26+
'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', //
27+
'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', ', '(', ')', '^', '﹊', '﹍', '╭', '╮', '╰', '╯', '', '_', //
28+
'', '^', '(', ':', '!', '/', '\\', '\"', '<', '>', '`', '{', '}', '~', '(', ')', '-', //
29+
'$', '@', '*', '&', '#', '卐', '㎎', '㎏', '㎜', '㎝', '㎞', '㎡', '㏄', '㏎', '㏑', '㏒', '㏕', '+', '=', '?',
30+
':', '.', '!', ';', ']','|','%');
3131

3232
/**
3333
* 判断指定的词是否是不处理的词。 如果参数为空,则返回true,因为空也属于不处理的字符。
34-
*
34+
*
3535
* @param ch 指定的词
3636
* @return 是否是不处理的词
3737
*/
@@ -41,7 +41,7 @@ public static boolean isStopChar(char ch) {
4141

4242
/**
4343
* 是否为合法字符(待处理字符)
44-
*
44+
*
4545
* @param ch 指定的词
4646
* @return 是否为合法字符(待处理字符)
4747
*/

hutool-dfa/src/test/java/cn/hutool/dfa/DfaTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package cn.hutool.dfa;
22

33
import cn.hutool.core.collection.CollUtil;
4-
import static org.junit.jupiter.api.Assertions.*;
54
import org.junit.jupiter.api.Test;
65

76
import java.util.List;
87

8+
import static org.junit.jupiter.api.Assertions.*;
9+
910
/**
1011
* DFA单元测试
1112
*
@@ -27,7 +28,7 @@ public void matchAllTest() {
2728
// 匹配到【大】,就不再继续匹配了,因此【大土豆】不匹配
2829
// 匹配到【刚出锅】,就跳过这三个字了,因此【出锅】不匹配(由于刚首先被匹配,因此长的被匹配,最短匹配只针对第一个字相同选最短)
2930
List<String> matchAll = tree.matchAll(text, -1, false, false);
30-
assertEquals(matchAll, CollUtil.newArrayList("大", "土^豆", "刚出锅"));
31+
assertEquals(CollUtil.newArrayList("大", "土^豆", "刚出锅"), matchAll);
3132
}
3233

3334
/**

0 commit comments

Comments
 (0)