AutoCorrrect for Rust
The CLI tool based on Rust is used to automatically correct, for add whitespace between CJK (Chinese, Japanese, Korean) and half-width characters (alphabetical letters, numerical digits and symbols).
It also supports programming source code correcting, based on Parser, can recognize the file name, and can find the strings and the comment part to correct.
基于 Rust 编写的 CLI 工具,用于自动纠正文案,给 CJK(中文、日语、韩语)与英文混写的场景,补充正确的空格,同时尝试以安全的方式自动纠正标点符号等等。
除了纯文本的自动纠正以外,AutoCorrect 基于 Parser 的方式对各种类型源代码文件支持,能自动识别文件名,并准确找到字符串、注释做自动纠正。
此方案最早于 2013 年 出现于 Ruby China 的项目,并逐步完善规则细节,当前准确率较高(级少数异常情况),你可以放心用来辅助你完整自动纠正动作。
VS Code Extension
https://marketplace.visualstudio.com/items?itemName=huacnlee.auto-correct
Features
- Auto add spacings between CJK (Chinese, Japanese, Korean) and English words.
- Multiple file content support (HTML, YAML, Rust, Go, SQL, Ruby, Python, Objective-C, Swift, Java, Kotlin, Dart, JavaScript, CSharp ...).
- Fullwidth -> halfwidth (only for [a-zA-Z0-9], and
:
in time). - Correct punctuations into Fullwidth near the CJK.
Other implements for programming
- Rust - autocorrect
- Ruby - auto-correct
- Go - go-auto-correct
Install
|
after that, you will get /usr/local/bin/autocorrect
command.
<file>...
)
)
Usage
Ignore for file
If you want ignore AutoCorrect for a file, you can put autocorrect: false
.
// autocorrect: false
Usage in Rust
In your Cargo.toml
[]
= "0.5.0"
Use autocorrect::format
to format plain text.
extern crate autocorrect;
Use autocorrect::format_html
to format html content.
extern crate autocorrect;
Benchmark
Format
Use cargo bench
to run benchmark tests.
)
)
)
Total chars | Duration |
---|---|
50 | 0.014 ms |
100 | 0.019 ms |
400 | 0.045 ms |
FormatHTML
TODO
License
This project under MIT license.