kakasi
kakasi is a Rust library to transliterate hiragana, katakana and kanji (Japanese text) into rōmaji (Latin/Roman alphabet).
It was ported from the pykakasi library which itself is a port of the original kakasi library written in C.
Usage
Transliterate:
let res = convert;
assert_eq!;
assert_eq!;
Check if a string contains Japanese characters:
use IsJapanese;
assert_eq!;
assert_eq!;
assert_eq!;
CLI
## Convert to romaji
## Convert to hiragana
## Read from file
## Read from STDIN
|
Performance
CPU: AMD Ryzen 7 5700G
| Text | Conversion time | Speed |
|---|---|---|
| Sentence (161 B) | 7.0911 µs | 22.70 MB/s |
| Rust wikipedia article (31705 B) | 1.5055 ms | 21.06 MB/s |
CLI comparison
Time to convert a 100KB test file using the CLI:
| Library | Time | Speed |
|---|---|---|
| kakasi (Rust) | 7.4 ms | 13.5 MB/s |
| kakasi (C) | 33.5 ms | 2.99 MB/s |
| pykakasi (Python) | 810.6 ms | 0.123 MB/s |
Test commands:
CLI performance was measured with hyperfine.
License
kakasi is published under the GNU GPL-3.0 license.
The Kakasi dictionaries (Files: codegen/dict/kakasidict.utf8, codegen/dict/itajidict.utf8,
codegen/dict/hepburn.utf8)
were taken from the pykakasi project,
published under the GNU GPL-3.0 license.
pykakasi
Copyright (C) 2010-2021 Hiroshi Miura and contributors(see AUTHORS)
The dictionaries originate from the kakasi project, published under the GNU GPL-2.0 license.
original kakasi
Copyright (C) 1992 1993 1994 Hironobu Takahashi (takahasi@tiny.or.jp), Masahiko Sato (masahiko@sato.riec.tohoku.ac.jp), Yukiyoshi Kameyama, Miki Inooka, Akihiko Sasaki, Dai Ando, Junichi Okukawa, Katsushi Sato and Nobuhiro Yamagishi
For testing I included a copy of the Japanese Rust wikipedia article
(tests/rust_article.txt). The article is published under the Creative Commons
Attribution-ShareAlike License 3.0.