Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hs-cn/simple-word-count

a simple word count function, try to get same result with Microsoft Office Word application.
https://github.com/hs-cn/simple-word-count

word-count word-counter

Last synced: about 2 months ago
JSON representation

a simple word count function, try to get same result with Microsoft Office Word application.

Awesome Lists containing this project

README

        

# Description
a simple word count function, try to get same result with Microsoft Office Word application.
**Not guarantee** same result on special characters. Such like Emoji β€œπŸ˜˜πŸ˜¦πŸ˜’β€ is count `1` in Microsoft Office Word, but `3` by word_count.

# Examples
``` rust
use simple_word_count::word_count;

fn main() {
assert_eq!(word_count("helloworld"), 1);
assert_eq!(word_count("hello world"), 2);
assert_eq!(word_count("hello, world"), 2);
assert_eq!(word_count("h e l l o w o r l d"), 10);
assert_eq!(word_count("hi......"), 1);
assert_eq!(word_count("hello, world | δ½ ε₯½οΌŒδΈ–η•Œ"), 8);
assert_eq!(word_count("δ½ ε₯½δΈ–η•Œ"), 4);
assert_eq!(word_count("δ½ ε₯½οΌŒδΈ–η•Œ"), 5);
assert_eq!(word_count("δ½  ε₯½ δΈ– η•Œ"), 4);
assert_eq!(word_count("δ½ ε₯½γ€‚。。。"), 6);
assert_eq!(word_count("a=b+c-d"), 1);
assert_eq!(word_count("a = b + c - d"), 7);
assert_eq!(word_count("123"), 1);
assert_eq!(word_count("123.456"), 1);
assert_eq!(word_count("123..456"), 1);
assert_eq!(word_count("123.456."), 1);
assert_eq!(word_count("123 456"), 2);
assert_eq!(word_count("1+1=2"), 1);
assert_eq!(word_count("1 + 1 = 2"), 5);
assert_eq!(word_count("&&%%$$οΏ₯οΏ₯"), 3);
assert_eq!(word_count("<>γ€Šγ€‹"), 3);
}
```