aboutsummaryrefslogtreecommitdiff
path: root/extract.sh
diff options
context:
space:
mode:
Diffstat (limited to 'extract.sh')
-rwxr-xr-xextract.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/extract.sh b/extract.sh
new file mode 100755
index 0000000..4ded1c0
--- /dev/null
+++ b/extract.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+db_file=games_anon.db
+
+query() {
+ echo "SELECT $1 FROM games WHERE (size == $2) \
+and (result != '1-0') and (result != '0-1') and (result != '0-0')\
+and (result != '1/2-1/2');"
+}
+
+extract() {
+ cd data
+ for size in 5 6; do
+ echo Extracing games of size "$size"...
+ sqlite3 "$db_file" "$(query $1 $size)" | shuf > "playtak-$size"
+ done
+}
+
+if [ ! -f "$db_file" ]; then
+ wget "https://www.playtak.com/games_anon.db"
+fi
+
+extract notation,result
+
+echo Preparing pptdb
+if [ ! -f "pptdb" ]; then
+ make pptdb
+fi
+echo -e "Beginning to process data\n"
+
+for i in 5 6; do
+ echo "Size $i..."
+ ./pptdb "$i" "data/playtak-$i" > "data/check-$i"
+ tail -n21 "data/check-$i"
+ echo Stripping overflows and illegal games...
+ grep -Fvxf "data/check-$i" "data/playtak-$i" > "data/good-playtak-$i"
+ echo -n "Generating training data... "
+ ./pptdb "$i" "data/good-playtak-$i" generate
+ echo "Shuffling data..."
+ shuf "data/training-$i.csv" > "data/shuf-$i.csv"
+ mv "data/shuf-$i.csv" "data/training-$i.csv"
+ echo
+done
+
+
+shuf -n50000 data/good-playtak-5 > data/smalltak-5 && ./pptdb 5 data/smalltak-5 generate && \
+head -n1 data/training-5.csv > t && tail -n+2 data/training-5.csv > test.csv && shuf test.csv >> t && mv t test.csv