Crates.io | fast2s |
lib.rs | fast2s |
version | 0.3.1 |
source | src |
created_at | 2021-10-31 02:55:25.661793 |
updated_at | 2022-06-07 03:45:42.629296 |
description | A fast Traditional Chinese to Simplified Chinese conversion library. Built with FST, faster than most of other libraries. |
homepage | https://github.com/tyrchen/fast2s |
repository | https://github.com/tyrchen/fast2s |
max_upload_size | |
id | 474583 |
size | 48,956 |
A super-fast Chinese translation tool to translate Traditional Chinese to Simplified Chinese.
Use hashbrown to build the translation state machine.
Usage:
let t = "企畫 計畫 企劃 計劃 畫圖 畫畫";
let s = fast2s::convert(k);
assert_eq!(&s, "企划 计划 企划 计划 画图 画画");
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 | 188us | 729us | 5.98ms | 1.23s |
zhc | 169us | 941us | 6.89ms | 2.87s |
en | 69us | 3.31ms | 13.99ms | 26.11s |
Test result (mutate existing string):
tests | fast2s | simplet2s-rs | opencc-rust | character_conver |
---|---|---|---|---|
zht | 121us | N/A | N/A | N/A |
zhc | 139us | N/A | N/A | N/A |
en | 78us | N/A | N/A | N/A |
Note:
Please do not trust the benchmark result directly, you shall run it in your local environment. See how to run benchmark.