CLI tool to rank proposals according to Majority Judgment, from an input CSV
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Go to file
Dominique Merle e93b3d8fa3
test: add smoke tests on some basic calls
3 years ago
.github/workflows test: add smoke tests on some basic calls 3 years ago
cmd feat: add a `--default` flag to pick the default judgment strategy 3 years ago
example test: more examples 3 years ago
formatter fix: median vertical line 3 years ago
version feat: also display the build date in `--version` 3 years ago
.gitignore chore(git): ignore windows builds 3 years ago
LICENSE feat: basic cobra boilerplate and usage doc 3 years ago
README.md feat: add a `--default` flag to pick the default judgment strategy 3 years ago
build.sh test: add smoke tests on some basic calls 3 years ago
go.mod test: add smoke tests on some basic calls 3 years ago
main.go feat: support --version to get the version 3 years ago
main_test.go test: add smoke tests on some basic calls 3 years ago

README.md

Majority Judgment CLI tool

MIT Release Build Status Code Quality A+ LoC Discord Chat

WORK IN PROGRESS Although the core mechanics are here and ranking does work, the features described in this README are not all implemented. We're merely doc-driving this tool, and our doc is ambitious.

  • Read from stdin with -
  • Read CSV file
  • --sort
  • --format text
  • --format json
  • --format csv
  • --format yml
  • --format gnuplot
  • --format svg
  • --chart
  • --default
  • --normalize

Download

Hand-made builds are provided in the Assets of each Release.

Usage

Say you have a tally CSV like so:

     , reject, poor, fair, good, very good, excellent
Pizza,      3,    2,    1,    4,         4,        2
Chips,      2,    3,    0,    4,         3,        4
Pasta,      4,    5,    1,    4,         0,        2

You can run

./mj example.csv

and get

Output of the command ; merit profiles are drawn in ASCII Art

You probably want to --sort the proposals as well:

./mj example.csv --sort

Output of the command ; the same but with sorted proposals

or use - to read from stdin:

cat example.csv | mj -

Balancing

Majority Judgment, to stay fair, requires tallies to be balanced ; all proposals must have received the same amount of judgments.

If your tally is not balanced, you may use a default judgment strategy:

mj example.csv --default 0
mj example.csv --default excellent
mj example.csv --default "très bien" --judges 42
mj example.csv --default majority
mj example.csv --normalize

Formats

You can specify the format:

./mj example.csv --format json > results.json
./mj example.csv --format csv > results.csv
./mj example.csv --format yml > results.yml
./mj example.csv --format svg > merit.svg

And even format gnuplot scripts that render charts:

./mj example.csv --format gnuplot | gnuplot

Linear merit profiles okf the proposals of a poll

You can specify the kind of chart you want:

./mj example.csv --format gnuplot --chart opinion | gnuplot

Available charts:

  • merit (default)
  • opinion
  • radial? (good first issue)

Install

Copy the binary somewhere in your PATH.

Or don't, and use it from anywhere.

Build

You can also grab the source and build it:

git clone https://github.com/MieuxVoter/majority-judgment-cli

Install golang.

Example:

  • Ubuntu: sudo snap install go --classic

Then go into this project directory and run:

go get
go build -o mj
./mj

Build distributables

We have a convenience script build.sh that will handle version embedding from git, using the clever govvv.

But basically, it's:

go build -ldflags "-s -w" -o mj

Yields a mj binary of about 5 Mio.

They say we should not strip go builds.

You can run upx on the binary to reduce its size:

upx mj

For Windows

GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o mj.exe

Packing the Windows executable with upx appears to trigger antivirus software.