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

no-std words-count

Count the words and characters, with or without whitespaces

2 releases

0.1.2 Apr 22, 2021
0.1.1 Aug 14, 2020
0.1.0 Aug 14, 2020

#365 in Text processing

MIT license

8KB
140 lines

Words Count

CI

Count the words and characters, with or without whitespaces.

Examples

extern crate words_count;

use words_count::WordsCount;

assert_eq!(WordsCount {
    words: 20,
    characters: 31,
    whitespaces: 2,
    cjk: 18,
}, words_count::count("Rust是由 Mozilla 主導開發的通用、編譯型程式語言。"));
extern crate words_count;

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.

Examples

extern crate words_count;

use words_count::WordsCount;

assert_eq!(WordsCount {
words: 20,
characters: 31,
whitespaces: 2,
cjk: 18,
}, words_count::count("Rust是由 Mozilla 主導開發的通用、編譯型程式語言。"));
extern crate words_count;

let result = words_count::count_separately("apple banana apple");

assert_eq!(2, result.len());
assert_eq!(Some(&2), result.get("apple"));

Dependencies

~66KB