Module bus.extra

Class NLPKit

java.lang.Object
org.miaixz.bus.extra.nlp.NLPKit

public class NLPKit extends Object
Utility class for Natural Language Processing (NLP) word segmentation. This class provides a facade for accessing various NLP segmentation engines, allowing for easy text parsing and word extraction.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • NLPKit

      public NLPKit()
  • Method Details

    • parse

      public static NLPResult parse(String text)
      Performs word segmentation on the given text using the default NLP engine.
      Parameters:
      text - The input text String to be segmented.
      Returns:
      An NLPResult object containing the segmented words and other NLP analysis results.
    • getEngine

      public static NLPProvider getEngine()
      Automatically creates and retrieves the corresponding word segmentation engine object. The engine is determined based on the NLP engine JARs introduced by the user via SPI mechanism.
      Returns:
      An NLPProvider instance, representing the chosen NLP segmentation engine.
    • createEngine

      public static NLPProvider createEngine(String engineName)
      Creates a word segmentation engine object with the specified engine name. This allows for explicit selection of an NLP provider when multiple are available.
      Parameters:
      engineName - The name of the NLP engine to create (e.g., "Ansj", "HanLP").
      Returns:
      An NLPProvider instance corresponding to the given engine name.