From eb2f78bdb8e485553b9e2e63040477fe574e88fd Mon Sep 17 00:00:00 2001 From: Joe Moudrik Date: Wed, 11 Jul 2012 10:33:39 +0200 Subject: [PATCH] tools/pattern_spatial_gen.sh: read input files from stdin if - commandline argument is present. --- tools/pattern_spatial_gen.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/pattern_spatial_gen.sh b/tools/pattern_spatial_gen.sh index c43bd52..16eac6c 100755 --- a/tools/pattern_spatial_gen.sh +++ b/tools/pattern_spatial_gen.sh @@ -5,6 +5,9 @@ # (we take files as arguments) and store these occuring more than 4 times # in a freshly created spatial dictionary; afterwards, you will probably want # to do standard pattern-matching. +# +# Instead of specifiing the files as arguments, the script reads filenames +# from stdin if you give '-' as an argument. # # DO NOT RUN THIS CONCURRENTLY! The dictionary will get corrupted. # @@ -27,8 +30,22 @@ rm -f $SPATIAL_DICT_FILE echo " Gathering population of spatials occuring more than $SPATMIN times..." -(for i in "$@"; do echo $i >&2; tools/sgf2gtp.py <$i; done) | - ./pachi -d 0 -e patternscan spatial_dict_filename=$SPATIAL_DICT_FILE,gen_spat_dict,no_pattern_match,spat_threshold=$SPATMIN${PATARGS:+,$PATARGS} >/dev/null +( +if [ "$1" = "-" ] ; then + while read i ; do + echo "$i" + done +else + for i in "$@"; do + echo "$i" + done +fi +) | ( +while read i ; do + echo "$i" >&2 + tools/sgf2gtp.py --stdout "$i" +done ) | ./pachi -d 0 -e patternscan spatial_dict_filename=$SPATIAL_DICT_FILE,gen_spat_dict,no_pattern_match,spat_threshold=$SPATMIN${PATARGS:+,$PATARGS} >/dev/null || exit 1 + echo " Renumbering patterns.spat..." perl -i -pe '/^#/ and next; s/^\d+/++$a/e' $SPATIAL_DICT_FILE -- 2.11.4.GIT