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

bin+lib word-tally

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

17 releases (9 breaking)

0.10.0 Sep 14, 2024
0.8.2 Jul 25, 2024

#976 in Command line utilities

Download history 41/week @ 2024-06-07 468/week @ 2024-06-14 233/week @ 2024-06-21 1/week @ 2024-06-28 7/week @ 2024-07-05 161/week @ 2024-07-19 208/week @ 2024-07-26 8/week @ 2024-08-02 113/week @ 2024-08-30 20/week @ 2024-09-06 247/week @ 2024-09-13 36/week @ 2024-09-20

416 downloads per month

MIT license

24KB
400 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] [INPUT]

Arguments:
  [INPUT]  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 [default: 1]
  -M, --min-count <COUNT>  Exclude words appearing fewer than min times [default: 1]
  -e, --exclude <WORDS>    Exclude any words from a comma-delimited list
  -O, --only <WORDS>       Only include 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
  -d, --debug              Print debugging information
  -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.10.0"

Or optionally enable JSON serialization and deserialization with Serde.

[dependencies]
word-tally = { version = "0.10.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