JapaneseStrategy#
- class scikitplot.corpus.JapaneseStrategy(*, tagger_args='-Owakati', sudachi_mode='C', custom_tokenizer_key='japanese')[source]#
Multi-tier Japanese segmentation strategy.
Probe order at
__init__time (first available wins, probed once):Custom tokenizer registered in
_TOKENIZER_REGISTRYunder key"japanese"— highest priority.MeCab via
mecab-python3(requires system MeCab binary).fugashi (pure-Python MeCab wrapper).
SudachiPy (pure-Python).
GraphemeClusterStrategy— guaranteed fallback.
- Parameters:
- tagger_argsstr, optional
Arguments forwarded to MeCab Tagger constructor. Default
"-Owakati"(space-delimited output).- sudachi_mode{“A”, “B”, “C”}, optional
SudachiPy split mode. A = shortest, C = longest morphemes. Default
"C".- custom_tokenizer_keystr, optional
Key to look up in the custom tokenizer registry. Default
"japanese".
- Parameters:
Notes
Developer note: The probe chain runs exactly once at
__init__time and caches the result inself._impl. Per-segment calls are an O(1) dispatch to the cached implementation.Examples
>>> strategy = JapaneseStrategy() >>> # strategy._impl is set to whichever backend was found
- segment(span, config)[source]#
Segment Japanese span using the probed backend.
- Parameters:
- spanScriptSpan
Hiragana or Katakana script span.
- configWritingSystemAdapterConfig
Adapter configuration.
- Returns:
- list[Chunk]
Non-empty list of morpheme/word chunks.
- Parameters:
span (ScriptSpan)
config (WritingSystemAdapterConfig)
- Return type: