java.lang.Object
org.miaixz.bus.extra.nlp.provider.ansj.AnsjProvider
- All Implemented Interfaces:
Serializable,org.miaixz.bus.core.Provider,NLPProvider
Ansj word segmentation engine implementation. This class serves as a concrete
NLPProvider for the Ansj NLP
library, adapting its word segmentation capabilities to the common NLP interface. Project homepage:
https://github.com/NLPchina/ansj_seg- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newAnsjProviderinstance with the default AnsjToAnalysistokenizer.AnsjProvider(org.ansj.splitWord.Analysis analysis) Constructs a newAnsjProviderinstance with a custom AnsjAnalysisimplementation. -
Method Summary
Modifier and TypeMethodDescriptionparse(CharSequence text) Performs word segmentation on the given text using the configured AnsjAnalysisinstance.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
-
AnsjProvider
public AnsjProvider()Constructs a newAnsjProviderinstance with the default AnsjToAnalysistokenizer. -
AnsjProvider
public AnsjProvider(org.ansj.splitWord.Analysis analysis) Constructs a newAnsjProviderinstance with a custom AnsjAnalysisimplementation.- Parameters:
analysis- The custom AnsjAnalysisobject to use for word segmentation.
-
-
Method Details
-
parse
Performs word segmentation on the given text using the configured AnsjAnalysisinstance. The result is wrapped in anAnsjResultto conform to theNLPResultinterface.- Specified by:
parsein interfaceNLPProvider- Parameters:
text- The input textCharSequenceto be segmented.- Returns:
- An
NLPResultobject containing the segmented words from Ansj.
-