Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alsotang/is_chinese_rs
detect whether a string is all Chinese
https://github.com/alsotang/is_chinese_rs
Last synced: 2 months ago
JSON representation
detect whether a string is all Chinese
- Host: GitHub
- URL: https://github.com/alsotang/is_chinese_rs
- Owner: alsotang
- Created: 2021-07-23T13:26:42.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-22T07:16:46.000Z (about 3 years ago)
- Last Synced: 2024-10-11T15:38:58.963Z (3 months ago)
- Language: Rust
- Size: 505 KB
- Stars: 6
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# is_chinese
[![crates.io](https://img.shields.io/crates/v/is_chinese.svg)](https://crates.io/crates/is_chinese)
detect whether a string is all Chinese
## example
```rust
use is_chinese;
assert!(is_chinese::is_chinese("中国"));
assert!(!is_chinese::is_chinese("ss"));
```## benchmark
test on MacBook Pro (16-inch, 2019) 2.6 GHz 六核Intel Core i7
```bash
is_chinese("扁担宽,板凳长,扁担想绑在板凳上。")
time: [46.530 ns 49.090 ns 52.108 ns]
change: [-30.027% -28.092% -26.047%] (p = 0.00 < 0.05)
Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
3 (3.00%) high mild
7 (7.00%) high severeis_chinese("ss扁担宽,板凳长,扁担想绑在板凳上。")
time: [1.8472 ns 1.8525 ns 1.8582 ns]
change: [+16.794% +18.154% +19.542%] (p = 0.00 < 0.05)
Performance has regressed.
Found 9 outliers among 100 measurements (9.00%)
3 (3.00%) high mild
6 (6.00%) high severeis_chinese("扁担宽,板凳长,扁担想绑在板凳上。ss")
time: [9.1091 ns 9.1742 ns 9.2601 ns]
change: [+60.777% +63.702% +66.532%] (p = 0.00 < 0.05)
Performance has regressed.
Found 9 outliers among 100 measurements (9.00%)
4 (4.00%) high mild
5 (5.00%) high severeisChinese(chars1000) true")
time: [2.0190 us 2.0553 us 2.1013 us]
change: [-31.444% -30.385% -29.334%] (p = 0.00 < 0.05)
Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
1 (1.00%) high mild
5 (5.00%) high severeis_chinese("isChinese(chars1001) false")
time: [50.272 ns 50.850 ns 51.482 ns]
change: [-51.617% -50.891% -50.187%] (p = 0.00 < 0.05)
Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
4 (4.00%) high mild
4 (4.00%) high severe
```## license
MIT