Module bus.extra

Class AnalysisResult

java.lang.Object
org.miaixz.bus.core.center.iterator.ComputeIterator<NLPWord>
org.miaixz.bus.extra.nlp.AbstractResult
org.miaixz.bus.extra.nlp.provider.analysis.AnalysisResult
All Implemented Interfaces:
Iterable<NLPWord>, Iterator<NLPWord>, org.miaixz.bus.core.center.iterator.IterableIterator<NLPWord>, NLPResult

public class AnalysisResult extends AbstractResult
Abstract result wrapper for Lucene-analysis word segmentation. This class adapts the Lucene TokenStream to the common NLPResult interface. Project homepage: https://github.com/apache/lucene-solr/tree/master/lucene/analysis
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • AnalysisResult

      public AnalysisResult(org.apache.lucene.analysis.TokenStream stream)
      Constructs an AnalysisResult instance by wrapping a Lucene TokenStream.
      Parameters:
      stream - The TokenStream obtained from Lucene analysis.
  • Method Details

    • nextWord

      protected NLPWord nextWord()
      Retrieves the next word from the Lucene TokenStream. This method calls incrementToken() on the stream and wraps the resulting CharTermAttribute in an AnalysisWord.
      Specified by:
      nextWord in class AbstractResult
      Returns:
      The next NLPWord in the sequence, or null if the iteration has no more elements.
      Throws:
      org.miaixz.bus.core.lang.exception.InternalException - if an IOException occurs during token processing.