Module bus.extra

Class AbstractResult

java.lang.Object
org.miaixz.bus.core.center.iterator.ComputeIterator<NLPWord>
org.miaixz.bus.extra.nlp.AbstractResult
All Implemented Interfaces:
Iterable<NLPWord>, Iterator<NLPWord>, org.miaixz.bus.core.center.iterator.IterableIterator<NLPWord>, NLPResult
Direct Known Subclasses:
AnalysisResult, JcsegResult, MmsegResult

public abstract class AbstractResult extends org.miaixz.bus.core.center.iterator.ComputeIterator<NLPWord> implements NLPResult
Abstract base class that decorates a regular result class (one that does not inherently implement Iterator) as an NLPResult. This class simplifies the implementation of NLPResult by requiring subclasses to only implement the nextWord() method to provide the next segmented word.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • AbstractResult

      public AbstractResult()
  • Method Details

    • nextWord

      protected abstract NLPWord nextWord()
      Retrieves the next word from the word segmentation result. This method should be implemented by subclasses to provide the logic for fetching the next NLPWord. Returns null when there are no more words to be processed.
      Returns:
      The next NLPWord in the sequence, or null if the iteration has no more elements.
    • computeNext

      protected NLPWord computeNext()
      Computes the next element in the iteration. This method is called by ComputeIterator to get the next word. It delegates to the abstract nextWord() method.
      Specified by:
      computeNext in class org.miaixz.bus.core.center.iterator.ComputeIterator<NLPWord>
      Returns:
      The next NLPWord or null if the iteration is complete.