Introduction
Japanese morphological analysis—the joint task of word segmentation, part-of-speech (POS) tagging, and lemmatization—is a fundamental prerequisite for downstream NLP tasks. While modern neural models offer high accuracy, their computational overhead often precludes real-time processing of massive datasets or deployment on edge devices. This paper introduces Jagger, a morphological analyzer that achieves a throughput of over 1,000,000 sentences per second on a single CPU by revisiting and optimizing classical pattern-based matching.
The Efficiency Gap in Japanese NLP
Unlike English, Japanese text lacks explicit word boundaries (spaces). Traditional tools like MeCab use Conditional Random Fields (CRFs) and Viterbi decoding to find the optimal segmentation path, which is accurate but computationally intensive. Conversely, simple "longest matching" algorithms are fast but error-prone. Jagger closes this gap by using a refined, data-driven pattern induction method that matches the accuracy of CRFs while maintaining the speed of deterministic greedy matching.
Methodology: Feature-Sequence Trie
Jagger's core innovation is the use of a Feature-Sequence Trie to store patterns learned from annotated training data. These patterns incorporate not just the word itself, but also its immediate right-hand context (posterior characters) and the POS tag of the preceding word.
Key Algorithmic Features:
- Joint Processing: Jagger performs segmentation and tagging simultaneously in a single left-to-right pass, significantly reducing overhead.
- Deterministic Greedy Matching: At each position, the system performs a longest prefix search in a double-array trie to find the most specific matching pattern. This pattern dictates the next word boundary and its associated tag.
- Pattern Pruning: To optimize memory and speed, the model only retains patterns that provide unique information not captured by their shorter prefixes.
Evaluation and Results
The system was evaluated on the Kyoto-University Text Corpus (KYOTO) and the Web Document Leads Corpus (KWDLC) using JUMAN morphological dictionaries.
Performance Benchmarks
- Throughput: Jagger processed over 1,000,000 sentences per second on an M2 MacBook Air, making it approximately 16 times faster than MeCab and 7 times faster than Vaporetto.
- Memory Footprint: Jagger is exceptionally lean, requiring only 26–40 MiB of memory, a fraction of the ~650–840 MiB required by modern classification-based tools like Vaporetto.
- Accuracy: On the KYOTO benchmark, Jagger achieved an F1 score of 96.57%, nearly identical to MeCab (96.10%) and within 0.5% of state-of-the-art neural models like JUMAN++-v2, despite being orders of magnitude faster.
Conclusion
Jagger demonstrates that "absolutely efficient" morphological analysis is possible without sacrificing significant accuracy. By leveraging optimized data structures and data-driven pattern induction, it provides a viable solution for processing web-scale data and running NLP pipelines on resource-constrained hardware. Future work includes extending this pattern-based approach to other languages and exploring the use of neural models to automatically generate high-efficiency discrete patterns.
Summary updated