java.lang.Object
org.miaixz.bus.extra.nlp.provider.jcseg.JcsegProvider
- All Implemented Interfaces:
Serializable,org.miaixz.bus.core.Provider,NLPProvider
Jcseg word segmentation engine implementation. This class serves as a concrete
NLPProvider for the Jcseg NLP
library. Note that ISegment is not thread-safe, so a new instance is created for each segmentation request.
Project homepage: https://gitee.com/lionsoul/jcseg- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newJcsegProviderinstance with a default configuration.JcsegProvider(org.lionsoul.jcseg.segmenter.SegmenterConfig config) Constructs a newJcsegProviderinstance with a customSegmenterConfig. -
Method Summary
Modifier and TypeMethodDescriptionparse(CharSequence text) Performs word segmentation on the given text using the Jcseg engine.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
-
JcsegProvider
public JcsegProvider()Constructs a newJcsegProviderinstance with a default configuration. It automatically finds and loads the `jcseg.properties` configuration file. -
JcsegProvider
public JcsegProvider(org.lionsoul.jcseg.segmenter.SegmenterConfig config) Constructs a newJcsegProviderinstance with a customSegmenterConfig.- Parameters:
config- The customSegmenterConfigto use for word segmentation.
-
-
Method Details
-
parse
Performs word segmentation on the given text using the Jcseg engine. A newISegmentinstance is created for each call to ensure thread safety. The result is wrapped in aJcsegResultto conform to theNLPResultinterface.- Specified by:
parsein interfaceNLPProvider- Parameters:
text- The input textCharSequenceto be segmented.- Returns:
- An
NLPResultobject containing the segmented words from Jcseg. - Throws:
org.miaixz.bus.core.lang.exception.InternalException- if anIOExceptionoccurs during the operation.
-