#chinese #convert #hanzi #traditional #localization #simplified

fast2s

A fast Traditional Chinese to Simplified Chinese conversion library. Built with FST, faster than most of other libraries.

5 unstable releases

0.3.1 Jun 7, 2022
0.3.0 Nov 3, 2021
0.2.1 Oct 31, 2021
0.2.0 Oct 31, 2021
0.1.0 Oct 31, 2021

#1529 in Text processing

Download history 338/week @ 2024-03-14 344/week @ 2024-03-21 501/week @ 2024-03-28 442/week @ 2024-04-04 357/week @ 2024-04-11 357/week @ 2024-04-18 443/week @ 2024-04-25 484/week @ 2024-05-02 654/week @ 2024-05-09 285/week @ 2024-05-16 370/week @ 2024-05-23 258/week @ 2024-05-30 495/week @ 2024-06-06 488/week @ 2024-06-13 388/week @ 2024-06-20 316/week @ 2024-06-27

1,756 downloads per month
Used in 5 crates (4 directly)

MIT license

26KB
223 lines

fast2s

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, "企划 计划 企划 计划 画图 画画");

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 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:

  1. benchmark is done with rust 1.56.1.
  2. 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.
  3. N/A means not supported.

Please do not trust the benchmark result directly, you shall run it in your local environment. See how to run benchmark.

Credits

t2s.txt is borrored from simplet2s.

Dependencies

~1.1–1.6MB
~28K SLoC