Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Commit

Permalink
Use infile instead of indir, for more flexible testing
Browse files Browse the repository at this point in the history
  • Loading branch information
joelpurra committed Jan 25, 2014
1 parent fe38aa3 commit 785caab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/extract/erroneous-votes.sh
Expand Up @@ -4,12 +4,12 @@
# Extract votings with corrections, normalize the names of those with correctins, and list the worst "offenders".

now=$(date -u +%FT%TZ)
indir="${1:-"$PWD"}"
infile="${1:-"$PWD/ep_votes.json"}"
outdir="${2:-"$PWD/$now"}"
mkdir -p "$outdir"

echo "Current date: $now"
echo "Input directory: $indir"
echo "Input ep_votes.json file: $infile"
echo "Output directory: $outdir"

# http://parltrack.euwiki.org/dumps/schema.html
Expand Down Expand Up @@ -90,6 +90,8 @@ def names(n):
]
EOF

<"$indir/ep_votes.json" jq --online-input "$getVotingsWithCorrectionals" > "$outdir/correctionals.json"
<"$infile" jq "$getVotingsWithCorrectionals" > "$outdir/correctionals.json"

<"$indir/correctionals.json" jq "$cleanCorrectionalNameObjectArrays" > "$outdir/correctionals.name-strings.json"
<"$outdir/correctionals.json" jq "$cleanCorrectionalNameObjectArrays" > "$outdir/correctionals.name-strings.json"

<"$outdir/correctionals.name-strings.json" jq '.[] | .abstain.names + .against.names + .for.names | .[]' | grep --invert-match '\[\]' | sort | uniq -c | sort -n > "$outdir/worst-offenders.json"
6 changes: 3 additions & 3 deletions src/extract/vote-counts.sh
Expand Up @@ -4,12 +4,12 @@
# Extract vote counts per voting, and display number of votings and number of votes.

now=$(date -u +%FT%TZ)
indir="${1:-"$PWD"}"
infile="${1:-"$PWD/ep_votes.json"}"
outdir="${2:-"$PWD"}/$now"
mkdir -p "$outdir"

echo "Current date: $now"
echo "Input directory: $indir"
echo "Input ep_votes.json file: $infile"
echo "Output directory: $outdir"

trim(){
Expand Down Expand Up @@ -50,7 +50,7 @@ read -d '' getTotalVoteCountsPerVoting <<"EOF"
)
EOF

<"$indir/ep_votes.json" jq --online-input "$getTotalVoteCountsPerVoting" > "$outdir/votecounts.log"
<"$infile" jq --online-input "$getTotalVoteCountsPerVoting" > "$outdir/votecounts.log"

totalVotings=$(<"$outdir/votecounts.log" wc -l | trim)

Expand Down

0 comments on commit 785caab

Please sign in to comment.