Module bus.extra

Class JcsegProvider

java.lang.Object
org.miaixz.bus.extra.nlp.provider.jcseg.JcsegProvider
All Implemented Interfaces:
Serializable, org.miaixz.bus.core.Provider, NLPProvider

public class JcsegProvider extends Object implements 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 Details

    • JcsegProvider

      public JcsegProvider()
      Constructs a new JcsegProvider instance 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 new JcsegProvider instance with a custom SegmenterConfig.
      Parameters:
      config - The custom SegmenterConfig to use for word segmentation.
  • Method Details

    • parse

      public NLPResult parse(CharSequence text)
      Performs word segmentation on the given text using the Jcseg engine. A new ISegment instance is created for each call to ensure thread safety. The result is wrapped in a JcsegResult to conform to the NLPResult interface.
      Specified by:
      parse in interface NLPProvider
      Parameters:
      text - The input text CharSequence to be segmented.
      Returns:
      An NLPResult object containing the segmented words from Jcseg.
      Throws:
      org.miaixz.bus.core.lang.exception.InternalException - if an IOException occurs during the operation.