java.lang.Object
org.miaixz.bus.extra.nlp.provider.mmseg.MmsegProvider
- All Implemented Interfaces:
Serializable,org.miaixz.bus.core.Provider,NLPProvider
mmseg4j word segmentation engine implementation. This class serves as a concrete
NLPProvider for the mmseg4j
NLP library. Note that MMSeg is not thread-safe, so a new instance is created for each segmentation request.
Project homepage: https://github.com/chenlb/mmseg4j-core- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newMmsegProviderinstance with the default segmentation algorithm, which isComplexSegusing the default singleton dictionary.MmsegProvider(com.chenlb.mmseg4j.Seg seg) Constructs a newMmsegProviderinstance with a specified segmentation algorithm. -
Method Summary
Modifier and TypeMethodDescriptionparse(CharSequence text) Performs word segmentation on the given text using the configured mmseg4jSeginstance.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
-
MmsegProvider
public MmsegProvider()Constructs a newMmsegProviderinstance with the default segmentation algorithm, which isComplexSegusing the default singleton dictionary. -
MmsegProvider
public MmsegProvider(com.chenlb.mmseg4j.Seg seg) Constructs a newMmsegProviderinstance with a specified segmentation algorithm.- Parameters:
seg- TheSegalgorithm to use for word segmentation (e.g.,ComplexSeg,SimpleSeg).
-
-
Method Details
-
parse
Performs word segmentation on the given text using the configured mmseg4jSeginstance. A newMMSeginstance is created for each call to ensure thread safety. The result is wrapped in anMmsegResultto conform to theNLPResultinterface.- Specified by:
parsein interfaceNLPProvider- Parameters:
text- The input textCharSequenceto be segmented.- Returns:
- An
NLPResultobject containing the segmented words from mmseg4j.
-