- Notifications
You must be signed in to change notification settings - Fork16
Utility library for checking and converting between Japanese characters - Hiragana, Katakana - and Romaji
License
PSeitz/wana_kana_rust
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
[dependencies]wana_kana ="4.0"
Utility library for checking and converting between Japanese characters - Hiragana, Katakana - and Romaji (Ported fromhttps://github.com/WaniKani/WanaKana V4.0.2)
use wana_kana::ConvertJapanese;assert_eq!("ワナカナ".to_romaji(),"wanakana");assert_eq!("WanaKana".to_hiragana(),"わなかな");assert_eq!("WANAKANA".to_kana(),"ワナカナ");
On Migrating to 2.0 some performance improvements have been implemented by using more efficient lookup structures and avoiding allocations.According to these results around 1000 words can be converted per millisecond on a Core i7-6700.
bench_hiragana_to_romaji 3,519 1,070 -2,449 -69.59% x 3.29 bench_kana_1 3,066 567 -2,499 -81.51% x 5.41 bench_kana_2 8,006 1,831 -6,175 -77.13% x 4.37 bench_katakana_to_hiragana 2,512 622 -1,890 -75.24% x 4.04 bench_katakana_to_katakana 1,664 629 -1,035 -62.20% x 2.65 bench_katakana_to_romaji 6,922 1,067 -5,855 -84.59% x 6.49 bench_romaji_to_hiragana 3,802 1,300 -2,502 -65.81% x 2.92 bench_romaji_to_katakana 4,361 1,929 -2,432 -55.77% x 2.26
Comparison ToWanaKana
A detailed analysis has been done in thebench_compare subfolder, the analysis below may be inaccurate.
A short comparison suggests around 25x performance
importtoKanafrom'./src/toKana';importtoHiraganafrom'./src/toHiragana';importtoKatakanafrom'./src/toKatakana';importtoRomajifrom'./src/toRomaji';console.time("yo")for(vari=0;i<1000;i++){toKana('aiueosashisusesonaninunenokakikukeko')toKana('AIUEOSASHISUSESONANINUNENOKAKIKUKEKO')toHiragana('aiueosashisusesonaninunenokakikukeko')toHiragana('アイウエオサシスセソナニヌネノカキクケコ')toKatakana('aiueosashisusesonaninunenokakikukeko')toKatakana('あいうえおさしすせそなにぬねのかきくけこ')toRomaji('あいうえおさしすせそなにぬねのかきくけこ')toRomaji('アイウエオサシスセソナニヌネノカキクケコ')}console.timeEnd("yo")
node -r esm run.js
externcrate wana_kana;use wana_kana::to_hiragana::to_hiragana;use wana_kana::to_katakana::to_katakana;use wana_kana::to_romaji::to_romaji;use wana_kana::to_kana::*;fnmain(){let start = std::time::Instant::now();for _in0..1000{to_kana("aiueosashisusesonaninunenokakikukeko");to_kana("AIUEOSASHISUSESONANINUNENOKAKIKUKEKO");to_hiragana("aiueosashisusesonaninunenokakikukeko");to_hiragana("アイウエオサシスセソナニヌネノカキクケコ");to_katakana("aiueosashisusesonaninunenokakikukeko");to_katakana("あいうえおさしすせそなにぬねのかきくけこ");to_romaji("あいうえおさしすせそなにぬねのかきくけこ");to_romaji("アイウエオサシスセソナニヌネノカキクケコ");}println!("{:?}", start.elapsed().as_millis());}
node -r esm run.js
253.231ms
cargo run --release --bin bench
9ms
cargo install wana_kana
will install 2 CLI tools:to_kana
andto_romaji
.
Both commands support pipingls | to_kana
and parametersto_romaji へろ をるど
.
About
Utility library for checking and converting between Japanese characters - Hiragana, Katakana - and Romaji
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors6
Uh oh!
There was an error while loading.Please reload this page.