Class SegmentService

java.lang.Object
com.bytedesk.ai.segment.SegmentService

@Service public class SegmentService extends Object
分词服务类
Author:
jackning
  • Field Details

    • PUNCTUATION_PATTERN

      private static final Pattern PUNCTUATION_PATTERN
      标点符号正则表达式
  • Constructor Details

    • SegmentService

      public SegmentService()
  • Method Details

    • segmentWords

      public List<String> segmentWords(String text)
      基础分词 - 返回词语列表
      Parameters:
      text - 待分词文本
      Returns:
      词语列表
    • segmentDetails

      public List<SegmentWordDetail> segmentDetails(String text)
      详细分词 - 返回包含位置信息的分词结果
      Parameters:
      text - 待分词文本
      Returns:
      详细分词结果列表
    • wordCount

      public Map<String,Integer> wordCount(String text)
      词频统计
      Parameters:
      text - 待分词文本
      Returns:
      词频统计Map
    • segment

      public SegmentResponse segment(SegmentRequest request)
      高性能分词接口
      Parameters:
      request - 分词请求
      Returns:
      分词响应
    • batchSegment

      public List<SegmentResponse> batchSegment(List<String> texts, String type)
      批量分词
      Parameters:
      texts - 文本列表
      type - 分词类型
      Returns:
      分词结果列表
    • filterWords

      public List<String> filterWords(List<String> words, boolean filterPunctuation, int minLength)
      过滤分词结果
      Parameters:
      words - 词语列表
      filterPunctuation - 是否过滤标点符号
      minLength - 最小词长度
      Returns:
      过滤后的词语列表