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):

  1. Custom tokenizer registered in _TOKENIZER_REGISTRY under key "japanese" — highest priority.

  2. MeCab via mecab-python3 (requires system MeCab binary).

  3. fugashi (pure-Python MeCab wrapper).

  4. SudachiPy (pure-Python).

  5. 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:
  • tagger_args (str)

  • sudachi_mode (str)

  • custom_tokenizer_key (str)

Notes

Developer note: The probe chain runs exactly once at __init__ time and caches the result in self._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:
Return type:

list[Chunk]