2024-07-29 14:15:56 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-11-08 10:53:16 +00:00
|
|
|
pendingPredictions=/home/nuno/Documents/core/forecasting/past/PredictResolveTally/pendingPredictions.txt
|
2020-04-11 13:13:34 +00:00
|
|
|
pendingPredictionsTemp="${pendingPredictions}.t"
|
2024-11-08 10:53:16 +00:00
|
|
|
resolvedPredictions=/home/nuno/Documents/core/forecasting/past/PredictResolveTally/resolvedPredictions.txt
|
2020-04-11 13:13:34 +00:00
|
|
|
|
|
|
|
function predict(){
|
|
|
|
read -p "> Statement: " statement
|
|
|
|
read -p "> Probability (%): " probability
|
|
|
|
read -p "> Date of resolution (year/month/day): " date
|
2024-11-08 10:53:16 +00:00
|
|
|
echo UNRESOLVED $date $probability $statement >> $pendingPredictions
|
2020-04-11 13:13:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function resolve(){
|
|
|
|
while IFS= read -r -u9 line || [[ -n "$line" ]]; do
|
|
|
|
|
2024-11-08 10:53:16 +00:00
|
|
|
resolutionState="$(cut -d' ' -f1 <<<"$line")"
|
|
|
|
date="$(cut -d' ' -f2 <<<"$line")"
|
|
|
|
probability="$(cut -d' ' -f3 <<<"$line")"
|
|
|
|
statement="$(cut -d' ' -f4 <<<"$line")"
|
2020-04-11 13:13:34 +00:00
|
|
|
|
|
|
|
today=$(date +"%Y/%m/%d")
|
|
|
|
if [[ "$today" > "$date" ]];
|
|
|
|
then
|
|
|
|
# Already passed
|
|
|
|
echo $statement "("$date")"
|
|
|
|
read -p "> (TRUE/FALSE) " resolutionState
|
2024-11-08 10:53:16 +00:00
|
|
|
echo -e "$resolutionState\t$date\t$probability\t$statement" >> $resolvedPredictions
|
2020-04-11 13:13:34 +00:00
|
|
|
else
|
|
|
|
# Not yet passed
|
|
|
|
echo $line >> $pendingPredictionsTemp
|
|
|
|
fi
|
|
|
|
done 9< "$pendingPredictions"
|
|
|
|
mv $pendingPredictionsTemp $pendingPredictions
|
|
|
|
}
|
|
|
|
|
|
|
|
function tally(){
|
|
|
|
|
|
|
|
numTRUEtens=0
|
|
|
|
numFALSEtens=0
|
|
|
|
for i in {0..100}
|
|
|
|
do
|
|
|
|
|
2024-11-08 10:53:16 +00:00
|
|
|
regExPatternTRUE="^TRUE.* ${i} "
|
|
|
|
regExPatternFALSE="^FALSE.* ${i} "
|
|
|
|
numTRUE="$(grep -c -e "$regExPatternTRUE" $resolvedPredictions)"
|
|
|
|
numFALSE="$(grep -c -e "$regExPatternFALSE" $resolvedPredictions)"
|
2020-04-11 13:13:34 +00:00
|
|
|
|
|
|
|
numTRUEtens=$((numTRUEtens+numTRUE))
|
|
|
|
numFALSEtens=$((numFALSEtens+numFALSE))
|
|
|
|
if [ $(( $i % 10 )) -eq 0 ] && [ $i -ne 0 ] ; then
|
|
|
|
echo $((i-10)) to $i : $numTRUEtens TRUE and $numFALSEtens FALSE
|
|
|
|
numTRUEtens=0
|
|
|
|
numFALSEtens=0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|