fix stopchars

This commit is contained in:
Looly 2025-02-17 13:03:46 +08:00
parent 6b843b1ca6
commit 26c40fb51c
2 changed files with 24 additions and 23 deletions

View File

@ -1,9 +1,9 @@
package cn.hutool.dfa; package cn.hutool.dfa;
import java.util.Set;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import java.util.Set;
/** /**
* 过滤词及一些简单处理 * 过滤词及一些简单处理
* *
@ -22,10 +22,10 @@ public class StopChar {
'⒔', '⒕', '⒖', '⒗', '⒘', '⒙', '⒚', '⒛', '⑴', '⑵', '⑶', '⑷', '⑸', '⑹', '⑺', '⑻', '⑼', '⑽', '⑾', '⑿', '⒀', // '⒔', '⒕', '⒖', '⒗', '⒘', '⒙', '⒚', '⒛', '⑴', '⑵', '⑶', '⑷', '⑸', '⑹', '⑺', '⑻', '⑼', '⑽', '⑾', '⑿', '⒀', //
'⒁', '⒂', '⒃', '⒄', '⒅', '⒆', '⒇', '', 'Ⅱ', 'Ⅲ', 'Ⅳ', '', 'Ⅵ', 'Ⅶ', 'Ⅷ', 'Ⅸ', '', 'Ⅺ', 'Ⅻ', '', // '⒁', '⒂', '⒃', '⒄', '⒅', '⒆', '⒇', '', 'Ⅱ', 'Ⅲ', 'Ⅳ', '', 'Ⅵ', 'Ⅶ', 'Ⅷ', 'Ⅸ', '', 'Ⅺ', 'Ⅻ', '', //
'', '¥', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', // '', '¥', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', //
'', '', '', '', '', '', '', '', '', '', '', '_', '', '', '', 'Ρ', // '', '', '', '', '', '', '', '', '', '', '', '', '', '_', '', '', '', '', 'Ρ', //
'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', // 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', //
'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', ', '﹊', '', '╭', '╮', '╰', '╯', '', '_', // 'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', ', '', '', '', '﹊', '', '╭', '╮', '╰', '╯', '', '_', //
'/', '\\', '\"', '<', '>', '`', '{', '}', '~', '(', ')', '-', // '', '^', '', '', '', '/', '\\', '\"', '<', '>', '`', '{', '}', '~', '(', ')', '-', //
'$', '@', '*', '&', '#', '卐', '㎎', '㎏', '㎜', '㎝', '㎞', '㎡', '㏄', '㏎', '㏑', '㏒', '㏕', '+', '=', '?', '$', '@', '*', '&', '#', '卐', '㎎', '㎏', '㎜', '㎝', '㎞', '㎡', '㏄', '㏎', '㏑', '㏒', '㏕', '+', '=', '?',
':', '.', '!', ';', ']','|','%'); ':', '.', '!', ';', ']','|','%');

View File

@ -1,11 +1,12 @@
package cn.hutool.dfa; package cn.hutool.dfa;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.List; import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
/** /**
* DFA单元测试 * DFA单元测试
* *
@ -27,7 +28,7 @@ public class DfaTest {
// 匹配到就不再继续匹配了因此大土豆不匹配 // 匹配到就不再继续匹配了因此大土豆不匹配
// 匹配到刚出锅就跳过这三个字了因此出锅不匹配由于刚首先被匹配因此长的被匹配最短匹配只针对第一个字相同选最短 // 匹配到刚出锅就跳过这三个字了因此出锅不匹配由于刚首先被匹配因此长的被匹配最短匹配只针对第一个字相同选最短
List<String> matchAll = tree.matchAll(text, -1, false, false); List<String> matchAll = tree.matchAll(text, -1, false, false);
assertEquals(matchAll, CollUtil.newArrayList("", "土^豆", "刚出锅")); assertEquals(CollUtil.newArrayList("", "土^豆", "刚出锅"), matchAll);
} }
/** /**