CLI tool to rank proposals according to Majority Judgment, from an input CSV

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

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-to 0
mj example.csv --default-to excellent
mj example.csv --default-to "très bien" --judges 42
mj example.csv --default-to-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

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.

Owner
Mieux Voter
L'association pour la promotion du jugement majoritaire
Mieux Voter
Comments
  • Handle floating-point values in the input CSV

    Handle floating-point values in the input CSV

    1. Detect the power of 10 we need (should we set a max, in case we get 0.333333…?)
    2. Multiply all values by that power of ten, to get integers
    3. Proceed as usual
    4. Perhaps pipe the multiplier to the charts so they can divide before rendering
  • Balancing with normalization

    Balancing with normalization

    When there are too many proposals to expect judges to express a judgment on all (or even most) of them, normalizing the amount of judgments per proposal makes sense.

    It would mean for example using percentages instead of the actual amounts.

    Since we don't want to risk floating-point errors, the core of the algorithm only accepts integers. We can normalize to the least common multiple (LCM), but that requires shenanigans with math/big, since those numbers can become huge very fast (when unlucky, but about 50% of my job is to care for unlucky people).

    I'm still exploring an API that would allow us to keep the core algo math/big free (hence keeping performance and simplicity).

    Meanwhile, we're working on accepting floating-point values in the CSV, by detecting with how many powers of 10 we need to multiply them to use them as integers without losing precision.

  • Add the `--judges` flag

    Add the `--judges` flag

    Override the guessed amount of judges with a provided value.

    mj example.csv --default majority --judges 23
    

    That value MUST be higher than, or equal to the maximum amount of judgments a proposal received.

  • add gnuplot script example that display merit profile

    add gnuplot script example that display merit profile

    This gnuplot script example could be used in a new exporter in order to display merit profile with gnuplot. It includes the dataset provided in readme.

    Usage:

    gnuplot ./test.plot
    

    Or:

    cat ./test.plot | gnuplot
    

    Result:

    image

  • Test with naughty strings

    Test with naughty strings

    Reinforce resilience with more extensive testing.

    • https://github.com/minimaxir/big-list-of-naughty-strings
    • https://github.com/robotframework/SeleniumLibrary/blob/master/atest/resources/testlibs/blns.json
  • Support detailed judgments per judge (ballots) as input as well

    Support detailed judgments per judge (ballots) as input as well

    Support a CSV with the (anonymized) individual ballots as input:

        Pizza,  Pasta, Chips
    excellent,   good,  poor
    very good, reject,  poor
    …
    

    Grade detection may be complex (or impossible in some cases). We can try our best with preset gradings (:lion: :warning: ), but we'll need a --grades flag to let users set their grades.

    There's also the possibility of using the first line of the CSV as grading, like so:

    reject, poor, good, very good, excellent
        Pizza,  Pasta, Chips
    excellent,   good,  poor
    very good, reject,  poor
    …
    

    This would start a big development arc, since there will be many possible plots from such detailed data.

    We also need to detect which form of the CSV is used as input, and that's not going to be pretty.

  • Display the defaulted judgments on the merit profiles

    Display the defaulted judgments on the merit profiles

    … somehow.

    Of note

    • Any grade should be able to have default judgments.
    • A single merit profile may have multiple grades with default judgments (eventually, when we let judges choose their default judgment strategy)
    • Heck, we'll probably need to handle delegated judgments as well
  • Output SVG

    Output SVG

    mj --format svg --chart merit > merit.svg
    

    I'm not going to take this on, since we already have gnuplot and my plate is full with detailed judgments as input and normalization.

    Make sure to ping @roipoussiere about this, since he gave the subject a lot of thought already.

Read from standard input and output a Haags translation of the given input.

haags Read from standard input and output a Haags translation of the given input. Building make && sudo make install You may also run go build on syst

Oct 23, 2022
Runc: a CLI tool for spawning and running containers on Linux according to the OCI specification

runc Introduction runc is a CLI tool for spawning and running containers on Linux according to the OCI specification. This repo contains a lightly mod

Dec 16, 2021
A simple script to run speedtest(offical) CLI tool and store the results in CSV

PeriodicBW A script made to run official speedtest.net binary periodically and store the results in a CSV file Installation Get the official speedtest

Aug 10, 2021
Aug 5, 2022
A go language implementation of a CLI, based on input directory files

A go language implementation of a CLI, based on input directory files, using tree output of all file names, based on input database links, dynamic reading of database table information, based on input swagger files to automate the generation of the RESTFUL API.

Aug 23, 2022
Easy to use library and CLI utility to generate Go struct from CSV files.

csv2struct Easy to use library and CLI utility to generate Go struct from CSV files. As a benefit, it's fully compatible with csvutil. So, structs gen

Nov 7, 2022
A fast diff tool for comparing csv files

csvdiff A fast diff tool for comparing csv files. What is csvdiff? Csvdiff is a difftool to compute changes between two csv files. It is not a traditi

Dec 28, 2022
Command-line tool to load csv and excel (xlsx) files and run sql commands
Command-line tool to load csv and excel (xlsx) files and run sql commands

csv-sql supports loading and saving results as CSV and XLSX files with data processing with SQLite compatible sql commands including joins.

Nov 2, 2022
Command line tool for processing client transaction data in CSV format

command line tool for processing client transaction data in CSV format. thank you for looking! build instructions: $ git clone https://github.com/lnit

Oct 29, 2021
Simple tool to convert a Parquet file to a CSV written in Go/ Golang

Parquet2CSV Parquet2CSV is a simple tool to convert a Parquet file to a CSV written in Go/ Golang Usage: parquet2csv <PATH_TO_PARQUET_FILE> This will

Nov 3, 2022
Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Jan 12, 2022
Idiomatic Go input parsing with subcommands, positional values, and flags at any position. No required project or package layout and no external dependencies.
Idiomatic Go input parsing with subcommands, positional values, and flags at any position. No required project or package layout and no external dependencies.

Sensible and fast command-line flag parsing with excellent support for subcommands and positional values. Flags can be at any position. Flaggy has no

Jan 1, 2023
Json-match - Command line util for matching values in a JSON input

json-match Match JSON input by specifying key and value > json-match -json '{\"p

Jan 12, 2022
Jan 27, 2022
Typo - Terminal input simulator for demos
Typo - Terminal input simulator for demos

typo Somehow, whenever I need to give a presentation or demo, my typing skills d

Mar 19, 2022
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.

dasel Dasel (short for data-selector) allows you to query and modify data structures using selector strings. Comparable to jq / yq, but supports JSON,

Jan 2, 2023
A simple command line for convert CSV in JSON
A simple command line for convert CSV in JSON

C2J A simple command line for convert CSV in JSON list of objects based on header. Install With Go 1.17 or higher: go install github.com/edermanoel94/

Dec 14, 2022
Smart and simple CSV processing on the command line

csvquote smart and simple CSV processing on the command line Are you looking for a way to process CSV data with standard UNIX shell commands? Are you

Dec 30, 2022
TIled map editor CSV export conversion to C array

tiled2c This tool is very simplistic and is a variation of the one written to convert between Tiled map editor CSV exports and a format for the sega s

Nov 28, 2021