#character #word-count #count

no-std words-count

Count the words and characters, with or without whitespaces

6 releases

0.1.6 Sep 8, 2023
0.1.5 Apr 12, 2023
0.1.4 Nov 4, 2022
0.1.3 Mar 19, 2022
0.1.1 Aug 14, 2020

#219 in Text processing

Download history 475/week @ 2024-06-16 437/week @ 2024-06-23 661/week @ 2024-06-30 479/week @ 2024-07-07 567/week @ 2024-07-14 516/week @ 2024-07-21 589/week @ 2024-07-28 1046/week @ 2024-08-04 481/week @ 2024-08-11 374/week @ 2024-08-18 407/week @ 2024-08-25 1160/week @ 2024-09-01 784/week @ 2024-09-08 412/week @ 2024-09-15 441/week @ 2024-09-22 412/week @ 2024-09-29

2,142 downloads per month
Used in 8 crates (5 directly)

MIT license

10KB
160 lines

Words Count

CI

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.

Examples

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"));

Crates.io

https://crates.io/crates/words-count

Documentation

https://docs.rs/words-count

License

MIT


lib.rs:

Words Count

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.

Examples

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"));

Dependencies

~68KB