Module bus.extra

Class MynlpProvider

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

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

    • MynlpProvider

      public MynlpProvider()
      Constructs a new MynlpProvider instance with a default Mynlp lexer. The default lexer is a bigram lexer with part-of-speech tagging and person name recognition enabled.
    • MynlpProvider

      public MynlpProvider(com.mayabot.nlp.segment.Lexer lexer)
      Constructs a new MynlpProvider instance with a custom Mynlp Lexer implementation.
      Parameters:
      lexer - The custom Lexer object to use for word segmentation.
  • Method Details

    • parse

      public NLPResult parse(CharSequence text)
      Performs word segmentation on the given text using the configured Mynlp Lexer instance. The result is wrapped in a MynlpResult 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 Mynlp.