Class ChineseSegmenter.Builder
java.lang.Object
cloud.opencode.base.string.unicode.ChineseSegmenter.Builder
- Enclosing class:
ChineseSegmenter
Builder for ChineseSegmenter.
ChineseSegmenter 构建器。
- Since:
- JDK 25, opencode-base-string V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Method Summary
Modifier and TypeMethodDescriptionAdds a custom word to the dictionary.addWords(Collection<String> words) Adds multiple custom words.build()Builds the segmenter.keepNumbers(boolean keep) Sets whether to keep numbers in results.keepPunctuation(boolean keep) Sets whether to keep punctuation in results.maxWordLength(int length) Sets the maximum word length for matching.
-
Method Details
-
addWord
Adds a custom word to the dictionary. 添加自定义词语。- Parameters:
word- the word - 词语- Returns:
- this builder
-
addWords
Adds multiple custom words. 添加多个自定义词语。- Parameters:
words- the words - 词语集合- Returns:
- this builder
-
maxWordLength
Sets the maximum word length for matching. 设置最大词语匹配长度。- Parameters:
length- the max length - 最大长度- Returns:
- this builder
-
keepPunctuation
Sets whether to keep punctuation in results. 设置是否保留标点符号。- Parameters:
keep- whether to keep - 是否保留- Returns:
- this builder
-
keepNumbers
Sets whether to keep numbers in results. 设置是否保留数字。- Parameters:
keep- whether to keep - 是否保留- Returns:
- this builder
-
build
-