2 # pattern_mm - Harvest patterns from game collection and compute feature strengths
4 # This is a "frontend" for the MM tool by Remi Coulom, that is assumed to be
5 # unpacked and compiled in the mm/ subdirectory - get it at
7 # http://remi.coulom.free.fr/Amsterdam2007/mm.tar.bz2
9 # It will scan a given SGF collection, collect patterns, and use the MM tool
10 # to compute the relative strength of various features. The output will be
12 # * patterns.spat: Dictionary of spatial feature positions
13 # * patterns.gamma: Gamma values of pattern features
15 # If you run this on hundreds of games, be sure you are doing it on local
16 # filesystem, with some free memory (and few GB of free disk for temporary data),
17 # and armed by a lot of patience - it can take long time (minutes, tens...).
20 echo "Gathering patterns..."
21 # This is a poor man's UNIX pipe from pattern_gather to pattern_enumerate.
24 (cat patterns |
sed -ne 's/^= //p' |
grep -v '^$' | .
/pattern_enumerate.pl
>/tmp
/patterns.enum
) &
25 PATARGS
=",competition" .
/pattern_gather.sh
"$@"
28 ls -l /tmp
/patterns.enum
30 # There must not be pipeline here, because of aux patterns.fdict file!
33 cat /tmp
/patterns.enum | .
/pattern_mminput.pl | mm
/mm
>/tmp
/patterns.mm
35 echo "Associating gamma values..."
36 cat /tmp
/patterns.mm |
sed 's/ */ /; s/^ //;' |
join -o 2.3,1.2 /tmp
/patterns.mm patterns.fdict |
sed 's/^s\.[0-9]*:/s:/' >patterns.gamma
38 rm -f /tmp
/patterns.enum
/tmp
/patterns.mm
40 ls -l patterns.gamma patterns.spat
41 echo "Leaving behind for analysis:"
42 ls -l patterns.fdict mm-with-freq.dat