#word-count #count #word #character #utf-8 #letter

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

#204 in Text processing

Download history 635/week @ 2023-12-12 534/week @ 2023-12-19 343/week @ 2023-12-26 794/week @ 2024-01-02 1040/week @ 2024-01-09 1319/week @ 2024-01-16 1043/week @ 2024-01-23 980/week @ 2024-01-30 841/week @ 2024-02-06 1038/week @ 2024-02-13 1109/week @ 2024-02-20 1492/week @ 2024-02-27 1434/week @ 2024-03-05 1029/week @ 2024-03-12 1401/week @ 2024-03-19 393/week @ 2024-03-26

4,645 downloads per month
Used in 6 crates (4 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