Module bus.extra

Class HanLPResult

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

public class HanLPResult extends Object implements NLPResult
Implementation of NLPResult for HanLP word segmentation results. This class wraps a List of Term objects from HanLP and provides an iterator over NLPWord objects, adapting HanLP's results to the common interface. Project homepage: https://github.com/hankcs/HanLP
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Summary

    Constructors
    Constructor
    Description
    HanLPResult(List<com.hankcs.hanlp.seg.common.Term> termList)
    Constructs a HanLPResult instance by wrapping a list of segmentation results from HanLP.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if there are more words in the segmentation result.
    Returns the next word in the segmentation result as an NLPWord.
    void
    Removes the last word returned by this iterator from the underlying collection.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator

    Methods inherited from interface org.miaixz.bus.core.center.iterator.IterableIterator

    iterator

    Methods inherited from interface java.util.Iterator

    forEachRemaining
  • Constructor Details

    • HanLPResult

      public HanLPResult(List<com.hankcs.hanlp.seg.common.Term> termList)
      Constructs a HanLPResult instance by wrapping a list of segmentation results from HanLP.
      Parameters:
      termList - A List of Term objects obtained from HanLP segmentation.
  • Method Details

    • hasNext

      public boolean hasNext()
      Checks if there are more words in the segmentation result.
      Specified by:
      hasNext in interface Iterator<NLPWord>
      Returns:
      true if there are more words; false otherwise.
    • next

      public NLPWord next()
      Returns the next word in the segmentation result as an NLPWord. This method wraps the HanLP Term into a HanLPWord.
      Specified by:
      next in interface Iterator<NLPWord>
      Returns:
      The next NLPWord in the iteration.
    • remove

      public void remove()
      Removes the last word returned by this iterator from the underlying collection. This operation is delegated to the underlying iterator.
      Specified by:
      remove in interface Iterator<NLPWord>