Crates.io | words-count |
lib.rs | words-count |
version | 0.1.6 |
source | src |
created_at | 2020-08-14 11:09:02.492664 |
updated_at | 2023-09-08 16:18:44.393473 |
description | Count the words and characters, with or without whitespaces. |
homepage | https://magiclen.org/words-count |
repository | https://github.com/magiclen/words-count |
max_upload_size | |
id | 276538 |
size | 10,273 |
Count the words and characters, with or without whitespaces.
The algorithm is roughly aligned with the way LibreOffice is counting words. This means that it does not exactly match the Unicode Text Segmentation standard.
use words_count::WordsCount;
assert_eq!(WordsCount {
words: 20,
characters: 31,
whitespaces: 2,
cjk: 18,
}, words_count::count("Rust是由 Mozilla 主導開發的通用、編譯型程式語言。"));
let result = words_count::count_separately("apple banana apple");
assert_eq!(2, result.len());
assert_eq!(Some(&2), result.get("apple"));
https://crates.io/crates/words-count