Class ChineseSegmenter.Builder

java.lang.Object
cloud.opencode.base.string.unicode.ChineseSegmenter.Builder
Enclosing class:
ChineseSegmenter

public static final class ChineseSegmenter.Builder extends Object
Builder for ChineseSegmenter. ChineseSegmenter 构建器。
Since:
JDK 25, opencode-base-string V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • addWord

      public ChineseSegmenter.Builder addWord(String word)
      Adds a custom word to the dictionary. 添加自定义词语。
      Parameters:
      word - the word - 词语
      Returns:
      this builder
    • addWords

      public ChineseSegmenter.Builder addWords(Collection<String> words)
      Adds multiple custom words. 添加多个自定义词语。
      Parameters:
      words - the words - 词语集合
      Returns:
      this builder
    • maxWordLength

      public ChineseSegmenter.Builder maxWordLength(int length)
      Sets the maximum word length for matching. 设置最大词语匹配长度。
      Parameters:
      length - the max length - 最大长度
      Returns:
      this builder
    • keepPunctuation

      public ChineseSegmenter.Builder keepPunctuation(boolean keep)
      Sets whether to keep punctuation in results. 设置是否保留标点符号。
      Parameters:
      keep - whether to keep - 是否保留
      Returns:
      this builder
    • keepNumbers

      public ChineseSegmenter.Builder keepNumbers(boolean keep)
      Sets whether to keep numbers in results. 设置是否保留数字。
      Parameters:
      keep - whether to keep - 是否保留
      Returns:
      this builder
    • build

      public ChineseSegmenter build()
      Builds the segmenter. 构建分词器。
      Returns:
      the segmenter - 分词器