Module bus.extra

Class AnalysisProvider

java.lang.Object
org.miaixz.bus.extra.nlp.provider.analysis.AnalysisProvider
All Implemented Interfaces:
Serializable, org.miaixz.bus.core.Provider, NLPProvider
Direct Known Subclasses:
SmartcnProvider

public class AnalysisProvider extends Object implements NLPProvider
Abstract provider for Lucene-analysis based word segmentation engines. This class provides a base implementation for integrating various Lucene analyzers. Project homepage: https://github.com/apache/lucene-solr/tree/master/lucene/analysis
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Details

    • AnalysisProvider

      public AnalysisProvider(org.apache.lucene.analysis.Analyzer analyzer)
      Constructs a new AnalysisProvider instance with a specified Lucene Analyzer.
      Parameters:
      analyzer - The Analyzer to use for word segmentation.
  • Method Details

    • parse

      public NLPResult parse(CharSequence text)
      Performs word segmentation on the given text using the configured Lucene Analyzer. It creates a TokenStream from the text and wraps it in an AnalysisResult.
      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 Lucene analyzer.
      Throws:
      org.miaixz.bus.core.lang.exception.InternalException - if an IOException occurs during token stream processing.