See https://github.com/oshikiri/count.pl
You can use it instead of sort | uniq -c
.
cat ./demo/text8 | tr ' ' '\n' | scount -a | \
jq '. | sort_by(.count) | reverse | .[0:3]'
See https://github.com/oshikiri/scount/releases.
go get github.com/oshikiri/scount
go install github.com/oshikiri/scount
and then add ~/go/bin
to $PATH
.
$ scount -h
Usage of scount:
-a Use approximate counting algorithm (default is naive counting)
-ae float
Epsilon of lossy counting algorithm (default 1e-05)
-as float
Support of lossy counting algorithm (default 2e-05)
-f int
Flush counting progress every X [msec] (default 200)
-n int
Print the top N items (default 10)
-q Suppress a progress report
# Create ./scount binary
go build
# Run tests
go test