#word-count #words #tally #count #command-line #command-line-tool

bin+lib word-tally

Output a tally of the number of times unique words appear in source input

22 releases (14 breaking)

0.15.0 Nov 21, 2024
0.13.0 Oct 10, 2024
0.8.2 Jul 25, 2024

#1077 in Command line utilities

Download history 120/week @ 2024-08-31 13/week @ 2024-09-07 244/week @ 2024-09-14 40/week @ 2024-09-21 405/week @ 2024-09-28 184/week @ 2024-10-05 31/week @ 2024-10-12 3/week @ 2024-10-19 110/week @ 2024-11-02 12/week @ 2024-11-09 118/week @ 2024-11-16 27/week @ 2024-11-23 12/week @ 2024-11-30

173 downloads per month

MIT license

24KB
420 lines

word-tally

Crates.io docs.rs GitHub Actions Workflow Status

Output a tally of the number of times unique words appear in source input.

Usage

Usage: word-tally [OPTIONS] [PATH]

Arguments:
  [PATH]  File path to use as input rather than stdin ("-") [default: -]

Options:
  -s, --sort <ORDER>       Sort order [default: desc] [possible values: desc, asc, unsorted]
  -c, --case <FORMAT>      Case normalization [default: lower] [possible values: original, upper, lower]
  -m, --min-chars <COUNT>  Exclude words containing fewer than min chars
  -M, --min-count <COUNT>  Exclude words appearing fewer than min times
  -e, --exclude <WORDS>    Exclude words from a comma-delimited list
  -d, --delimiter <VALUE>  Delimiter between keys and values [default: " "]
  -o, --output <PATH>      Write output to file rather than stdout
  -v, --verbose            Print verbose details
  -h, --help               Print help
  -V, --version            Print version

Examples

> word-tally README.md | head -n3
tally 22
word 20
https 11
> word-tally --delimiter="," --output="tally.csv" README.md

Installation

cargo install word-tally

Cargo.toml

Add word-tally as a dependency.

[dependencies]
word-tally = "0.15.0"

Or optionally enable JSON serialization and deserialization with Serde.

[dependencies]
word-tally = { version = "0.15.0", features = ["serde"] }

Documentation

https://docs.rs/word-tally

Tests & benchmarks

Clone the repository.

git clone https://github.com/havenwood/word-tally
cd word-tally

Run the tests.

cargo test

Or run the tests with the Serde feature included.

cargo test --features serde

And run the benchmarks.

cargo bench

Dependencies

~2.3–3.5MB
~57K SLoC