How worksapplications/sudachi works
Project type and purpose
• Sudachi is a library-and-CLI tool for Japanese morphological analysis (segmentation, POS tagging, normalization).
• It provides both a Java API (for embedding in applications) and a command-line interface (CLI).
• It uses a plugin architecture to let users extend normalization, unknown-word handling, connection cost, path rewriting, and formatting.
File structure
• Top-level build: Gradle scripts (build.gradle, settings.gradle, gradlew), GitHub workflows (CI/CD), and LICENSE/README.
• src/main/java: core Java packages under com.worksap.nlp.sudachi, with subpackages for dictionary access, dictionary building, sentence detection, plugins, and the CLI entry point (SudachiCommandLine).
• src/main/resources: configuration files (sudachi.json, char.def, rewrite.def, unk.def) and logging properties.
• src/jmh: JMH benchmarks for core components (dictionary lookup, builder performance).
• benchmark/: shell scripts and Java driver for real-world corpus benchmarking.
• src/test: unit and integration tests covering core, dictionary build, plugin behavior, and CLI functionality.
README for additional insights
• The core workflow: input text → normalization → segmentation (mode A/B/C) → POS tagging → output formatting.
• Plugin types and extension points:
– InputTextPlugin (normalization)
– OovProviderPlugin (unknown-word generation)
– ConnectionCostPlugin (override connection costs)
– PathRewritePlugin (alter best path)
– MorphemeFormatterPlugin (alter output)
• Dictionaries: binary system dictionaries (small, core, full) loaded via memory-mapped files (MMap) and double-array lexicon structures.
Essential architectural elements
• Plugin loading and extension points clearly.
• Do not overload with every class—group related classes (e.g., all dictionary-build classes under “Dictionary Builder”).
• Resource/configuration dependencies (JSON, .def files) are visible.