switch csv => tsv
This commit is contained in:
		
							parent
							
								
									3a2745e382
								
							
						
					
					
						commit
						ed1904583e
					
				
							
								
								
									
										25
									
								
								PRT.bash
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								PRT.bash
									
									
									
									
									
								
							|  | @ -1,24 +1,23 @@ | ||||||
| #!/bin/bash | #!/bin/bash | ||||||
| 
 | 
 | ||||||
| pendingPredictions=/home/pendingPredictions.txt | pendingPredictions=/home/nuno/Documents/core/forecasting/past/PredictResolveTally/pendingPredictions.txt | ||||||
| pendingPredictionsTemp="${pendingPredictions}.t" | pendingPredictionsTemp="${pendingPredictions}.t" | ||||||
| resolvedPredictions=/home/resolvedPredictions.txt | resolvedPredictions=/home/nuno/Documents/core/forecasting/past/PredictResolveTally/resolvedPredictions.txt | ||||||
| 
 | 
 | ||||||
| function predict(){ | function predict(){ | ||||||
|         read -p "> Statement: " statement |         read -p "> Statement: " statement | ||||||
|         read -p "> Probability (%): " probability |         read -p "> Probability (%): " probability | ||||||
|         read -p "> Date of resolution (year/month/day): " date |         read -p "> Date of resolution (year/month/day): " date | ||||||
|         echo UNRESOLVED,$date,$probability,$statement >> $pendingPredictions |         echo UNRESOLVED	$date	$probability	$statement >> $pendingPredictions | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function resolve(){ | function resolve(){ | ||||||
|         > $pendingPredictions |  | ||||||
|         while IFS= read -r -u9 line || [[ -n "$line" ]]; do |         while IFS= read -r -u9 line || [[ -n "$line" ]]; do | ||||||
| 
 | 
 | ||||||
|                 resolutionState="$(cut -d',' -f1 <<<"$line")" |                 resolutionState="$(cut -d'	' -f1 <<<"$line")" | ||||||
|                 date="$(cut -d',' -f2 <<<"$line")" |                 date="$(cut -d'	' -f2 <<<"$line")" | ||||||
|                 probability="$(cut -d',' -f3 <<<"$line")" |                 probability="$(cut -d'	' -f3 <<<"$line")" | ||||||
|                 statement="$(cut -d',' -f4 <<<"$line")" |                 statement="$(cut -d'	' -f4 <<<"$line")" | ||||||
|                  |                  | ||||||
|                 today=$(date +"%Y/%m/%d")  |                 today=$(date +"%Y/%m/%d")  | ||||||
|                 if [[ "$today" > "$date" ]];  |                 if [[ "$today" > "$date" ]];  | ||||||
|  | @ -26,7 +25,7 @@ function resolve(){ | ||||||
|                         # Already passed |                         # Already passed | ||||||
|                         echo $statement "("$date")" |                         echo $statement "("$date")" | ||||||
|                         read -p "> (TRUE/FALSE) " resolutionState |                         read -p "> (TRUE/FALSE) " resolutionState | ||||||
|                         echo $resolutionState,$date,$probability,$statement >> $resolvedPredictions |                         echo -e "$resolutionState\t$date\t$probability\t$statement" >> $resolvedPredictions | ||||||
|                 else |                 else | ||||||
|                         # Not yet passed  |                         # Not yet passed  | ||||||
|                         echo $line >> $pendingPredictionsTemp    |                         echo $line >> $pendingPredictionsTemp    | ||||||
|  | @ -42,10 +41,10 @@ function tally(){ | ||||||
|         for i in {0..100} |         for i in {0..100} | ||||||
|         do |         do | ||||||
| 
 | 
 | ||||||
|                 regExPatternTRUE="TRUE.*,${i}," |                 regExPatternTRUE="^TRUE.*	${i}	" | ||||||
|                 regExPatternFALSE="FALSE.*,${i}," |                 regExPatternFALSE="^FALSE.*	${i}	" | ||||||
|                 numTRUE="$(grep -c -e $regExPatternTRUE $resolvedPredictions)" |                 numTRUE="$(grep -c -e "$regExPatternTRUE" $resolvedPredictions)" | ||||||
|                 numFALSE="$(grep -c -e $regExPatternFALSE $resolvedPredictions)" |                 numFALSE="$(grep -c -e "$regExPatternFALSE" $resolvedPredictions)" | ||||||
| 
 | 
 | ||||||
|                 numTRUEtens=$((numTRUEtens+numTRUE)) |                 numTRUEtens=$((numTRUEtens+numTRUE)) | ||||||
|                 numFALSEtens=$((numFALSEtens+numFALSE)) |                 numFALSEtens=$((numFALSEtens+numFALSE)) | ||||||
|  |  | ||||||
|  | @ -58,9 +58,11 @@ resolvedPredictions=/home/nuno/Documents/Forecasting/resolvedPredictions.txt | ||||||
| ## Gotchas | ## Gotchas | ||||||
| 
 | 
 | ||||||
| CSV | CSV | ||||||
| - Statements, predictions and probabilities are saved, internally, as a csv | - Statements, predictions and probabilities are saved, internally, as a tsv | ||||||
|   file. |   file. | ||||||
| - This requires not using commas in your statements | - This requires not using tabs in your statements | ||||||
|  | - A previous version required not using commas instead, but this has now | ||||||
|  |   changed | ||||||
| 
 | 
 | ||||||
| Dates:  | Dates:  | ||||||
| - Dates are in the year/month/day format, so that they can be compared  | - Dates are in the year/month/day format, so that they can be compared  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user