2012-05-18 19:53:11 -07:00
|
|
|
#!/usr/bin/awk -f
|
|
|
|
|
2011-06-01 02:06:18 -07:00
|
|
|
# read a list of decks in chronological order and produce a score for each card that appears
|
|
|
|
|
|
|
|
# skip comments
|
|
|
|
/^#/ {
|
|
|
|
next
|
|
|
|
prev = ""
|
|
|
|
}
|
|
|
|
|
2013-02-14 21:45:39 -08:00
|
|
|
/^\/\// {
|
|
|
|
next
|
|
|
|
prev = ""
|
|
|
|
}
|
|
|
|
|
2011-06-01 02:06:18 -07:00
|
|
|
{
|
|
|
|
# decay of scores
|
|
|
|
if (FILENAME != prev) {
|
|
|
|
for (i in score) {
|
2012-05-21 22:07:46 -07:00
|
|
|
score[i] = 0.95 * score[i]
|
2011-06-01 02:06:18 -07:00
|
|
|
}
|
|
|
|
prev = FILENAME
|
|
|
|
}
|
|
|
|
|
2013-02-14 21:45:39 -08:00
|
|
|
# to normalize mwDeck format
|
|
|
|
gsub("\\[.*\\]", "")
|
|
|
|
gsub("SB:", "")
|
|
|
|
gsub("^ *", "")
|
2013-02-14 22:23:21 -08:00
|
|
|
gsub(" +", " ")
|
2011-06-01 02:06:18 -07:00
|
|
|
|
|
|
|
s = gensub("^([0-9]*) ", "\\1|", "g", $0)
|
|
|
|
#print s
|
|
|
|
split(s, tok, "|")
|
|
|
|
#print "|"tok[1]"|"
|
|
|
|
cnt = tok[1]
|
|
|
|
gsub("|","",tok[2])
|
|
|
|
#print "|"tok[2]"|"
|
|
|
|
name = tok[2]
|
|
|
|
|
|
|
|
score[name] += cnt
|
|
|
|
}
|
|
|
|
|
|
|
|
END {
|
|
|
|
for (i in score) {
|
|
|
|
print score[i] "\t" i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|