Module bus.extra

Class AnsjProvider

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

public class AnsjProvider extends Object implements NLPProvider
Ansj word segmentation engine implementation. This class serves as a concrete NLPProvider for the Ansj NLP library, adapting its word segmentation capabilities to the common NLP interface. Project homepage: https://github.com/NLPchina/ansj_seg
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new AnsjProvider instance with the default Ansj ToAnalysis tokenizer.
    AnsjProvider(org.ansj.splitWord.Analysis analysis)
    Constructs a new AnsjProvider instance with a custom Ansj Analysis implementation.
  • Method Summary

    Modifier and Type
    Method
    Description
    Performs word segmentation on the given text using the configured Ansj Analysis 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

    • AnsjProvider

      public AnsjProvider()
      Constructs a new AnsjProvider instance with the default Ansj ToAnalysis tokenizer.
    • AnsjProvider

      public AnsjProvider(org.ansj.splitWord.Analysis analysis)
      Constructs a new AnsjProvider instance with a custom Ansj Analysis implementation.
      Parameters:
      analysis - The custom Ansj Analysis object to use for word segmentation.
  • Method Details

    • parse

      public NLPResult parse(CharSequence text)
      Performs word segmentation on the given text using the configured Ansj Analysis instance. The result is wrapped in an AnsjResult 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 Ansj.