Module bus.extra

Class WordProvider

java.lang.Object
org.miaixz.bus.extra.nlp.provider.word.WordProvider
All Implemented Interfaces:
Serializable, org.miaixz.bus.core.Provider, NLPProvider

public class WordProvider extends Object implements NLPProvider
Word word segmentation engine implementation. This class serves as a concrete NLPProvider for the Word NLP library, adapting its word segmentation capabilities to the common NLP interface. The underlying Segmentation is thread-safe. Project homepage: https://github.com/ysc/word
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new WordProvider instance with the default segmentation algorithm, which is SegmentationAlgorithm.BidirectionalMaximumMatching.
    WordProvider(org.apdplat.word.segmentation.Segmentation segmentation)
    Constructs a new WordProvider instance with a custom Segmentation implementation.
    WordProvider(org.apdplat.word.segmentation.SegmentationAlgorithm algorithm)
    Constructs a new WordProvider instance with a specified segmentation algorithm.
  • Method Summary

    Modifier and Type
    Method
    Description
    Performs word segmentation on the given text using the configured Word Segmentation instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.miaixz.bus.extra.nlp.NLPProvider

    type
  • Constructor Details

    • WordProvider

      public WordProvider()
      Constructs a new WordProvider instance with the default segmentation algorithm, which is SegmentationAlgorithm.BidirectionalMaximumMatching.
    • WordProvider

      public WordProvider(org.apdplat.word.segmentation.SegmentationAlgorithm algorithm)
      Constructs a new WordProvider instance with a specified segmentation algorithm.
      Parameters:
      algorithm - The SegmentationAlgorithm to use for word segmentation.
    • WordProvider

      public WordProvider(org.apdplat.word.segmentation.Segmentation segmentation)
      Constructs a new WordProvider instance with a custom Segmentation implementation.
      Parameters:
      segmentation - The custom Segmentation object to use for word segmentation.
  • Method Details

    • parse

      public NLPResult parse(CharSequence text)
      Performs word segmentation on the given text using the configured Word Segmentation instance. The result is wrapped in a WordResult to conform to the NLPResult interface.
      Specified by:
      parse in interface NLPProvider
      Parameters:
      text - The input text CharSequence to be segmented.
      Returns:
      An NLPResult object containing the segmented words from the Word library.