fast2s
A super-fast Chinese translation tool to translate Traditional Chinese to Simplified Chinese.
Use fst to build the translation state machine.
Usage:
let t = "企畫 計畫 企劃 計劃 畫圖 畫畫";
let s = convert;
assert_eq!;
Benchmark
See simple.rs under benches directory. I compared the result with opencc-rust, simplet2s-rs, and character_converter. As character_converter is too slow, I have to change the sample size to 10 to not wait super long.
Test result (convert and return new string):
tests | fast2s | simplet2s-rs | opencc-rust | character_conver |
---|---|---|---|---|
zht | 446us | 616us | 5.08ms | 1.23s |
zhc | 491us | 798us | 6.08ms | 2.87s |
en | 68us | 2.82ms | 12.24ms | 26.11s |
Test result (mutate existing string):
tests | fast2s | simplet2s-rs | opencc-rust | character_conver |
---|---|---|---|---|
zht | 438us | N/A | N/A | N/A |
zhc | 503us | N/A | N/A | N/A |
en | 34us | N/A | N/A | N/A |
Note:
- zht means load "math_zht.txt" and translate, zhc means load "math_zhc.txt" (all Simplified Chinese) and translate, en means load "math_en.txt" (all English) and translate.
- N/A means not supported.
Please do not trust the benchmark result directly, you shall run it in your local environment.