java.lang.Object
org.miaixz.bus.extra.nlp.provider.word.WordProvider
- All Implemented Interfaces:
Serializable,org.miaixz.bus.core.Provider,NLPProvider
Word word segmentation engine implementation. This class serves as a concrete
NLPProvider for the Word NLP
library, adapting its word segmentation capabilities to the common NLP interface. The underlying Segmentation
is thread-safe. Project homepage: https://github.com/ysc/word- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newWordProviderinstance with the default segmentation algorithm, which isSegmentationAlgorithm.BidirectionalMaximumMatching.WordProvider(org.apdplat.word.segmentation.Segmentation segmentation) Constructs a newWordProviderinstance with a customSegmentationimplementation.WordProvider(org.apdplat.word.segmentation.SegmentationAlgorithm algorithm) Constructs a newWordProviderinstance with a specified segmentation algorithm. -
Method Summary
Modifier and TypeMethodDescriptionparse(CharSequence text) Performs word segmentation on the given text using the configured WordSegmentationinstance.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
-
WordProvider
public WordProvider()Constructs a newWordProviderinstance with the default segmentation algorithm, which isSegmentationAlgorithm.BidirectionalMaximumMatching. -
WordProvider
public WordProvider(org.apdplat.word.segmentation.SegmentationAlgorithm algorithm) Constructs a newWordProviderinstance with a specified segmentation algorithm.- Parameters:
algorithm- TheSegmentationAlgorithmto use for word segmentation.
-
WordProvider
public WordProvider(org.apdplat.word.segmentation.Segmentation segmentation) Constructs a newWordProviderinstance with a customSegmentationimplementation.- Parameters:
segmentation- The customSegmentationobject to use for word segmentation.
-
-
Method Details
-
parse
Performs word segmentation on the given text using the configured WordSegmentationinstance. The result is wrapped in aWordResultto conform to theNLPResultinterface.- Specified by:
parsein interfaceNLPProvider- Parameters:
text- The input textCharSequenceto be segmented.- Returns:
- An
NLPResultobject containing the segmented words from the Word library.
-