java.lang.Object
org.miaixz.bus.extra.nlp.provider.hanlp.HanLPProvider
- All Implemented Interfaces:
Serializable,org.miaixz.bus.core.Provider,NLPProvider
HanLP word segmentation engine implementation. This class serves as a concrete
NLPProvider for the HanLP NLP
library, adapting its word segmentation capabilities to the common NLP interface. The underlying
Segment.seg(String) method is thread-safe. Project homepage:
https://github.com/hankcs/HanLP- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newHanLPProviderinstance with a default HanLP segmenter, created viaHanLP.newSegment().HanLPProvider(com.hankcs.hanlp.seg.Segment seg) Constructs a newHanLPProviderinstance with a custom HanLPSegmentimplementation. -
Method Summary
Modifier and TypeMethodDescriptionparse(CharSequence text) Performs word segmentation on the given text using the configured HanLPSegmentinstance.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.miaixz.bus.extra.nlp.NLPProvider
type
-
Constructor Details
-
HanLPProvider
public HanLPProvider()Constructs a newHanLPProviderinstance with a default HanLP segmenter, created viaHanLP.newSegment(). -
HanLPProvider
public HanLPProvider(com.hankcs.hanlp.seg.Segment seg) Constructs a newHanLPProviderinstance with a custom HanLPSegmentimplementation.- Parameters:
seg- The customSegmentobject to use for word segmentation.
-
-
Method Details
-
parse
Performs word segmentation on the given text using the configured HanLPSegmentinstance. The result is wrapped in aHanLPResultto conform to theNLPResultinterface.- Specified by:
parsein interfaceNLPProvider- Parameters:
text- The input textCharSequenceto be segmented.- Returns:
- An
NLPResultobject containing the segmented words from HanLP.
-