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

bin+lib word-tally

输出源输入中唯一单词出现的次数统计

15 个版本 (7 个破坏性版本)

0.8.2 2024 年 7 月 25 日
0.7.2 2024 年 6 月 21 日

983命令行工具

Download history 574/week @ 2024-05-15 376/week @ 2024-05-22 6/week @ 2024-05-29 141/week @ 2024-06-05 418/week @ 2024-06-12 279/week @ 2024-06-19 6/week @ 2024-06-26 7/week @ 2024-07-03 356/week @ 2024-07-24 21/week @ 2024-07-31

每月 377 次下载

MIT 许可证

21KB
322

word-tally

Crates.io docs.rs GitHub Actions Workflow Status

输出源输入中唯一单词出现的次数统计。

用法

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

示例

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

安装

cargo install word-tally

Cargo.toml

word-tally 添加为依赖项。

[dependencies]
word-tally = "0.8.2"

或者可选地使用 Serde 启用 JSON 序列化和反序列化。

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

文档

https://docs.rs/word-tally

测试 & 基准测试

克隆仓库。

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

运行测试。

cargo test

或者运行包含 Serde 功能的测试。

cargo test --features serde

并运行基准测试。

cargo bench

依赖项

~2.5–3.5MB
~62K SLoC