Autodetect grammar type
authorEnrico Zini <enrico@enricozini.org>
Thu, 13 Aug 2009 16:09:01 +0000 (17:09 +0100)
committerEnrico Zini <enrico@enricozini.org>
Thu, 13 Aug 2009 16:09:01 +0000 (17:09 +0100)
src/update-polygen-info

index 6b91f5d6ecb05c5a173213e9cdf128d8f3ef130b..0b44c4498b14bec73d71fe17480b5c5756e88148 100755 (executable)
@@ -8,21 +8,23 @@ cd /usr/share/polygen
 find . -name "*.grm" | sort | while read NAME
 do
        TITLE=`polygen -info $NAME | grep ^title: | head -1 | sed -re 's/^[^:]+: *//'`
-       NAME=${NAME:2}
-       NAME=${NAME%.grm}
-
-       if grep -Fqx $NAME ~/.zavai/polygen-line-text
+       if [ "`polygen $NAME | head -n 1 | cut -c 1`" == '<' ]
        then
-               TYPE="line/text"
-       elif grep -Fqx $NAME ~/.zavai/polygen-line-html
-       then
-               TYPE="line/html"
-       elif grep -Fqx $NAME ~/.zavai/polygen-block-html
+               T2="html"
+       else
+               T2="text"
+       fi
+
+       if [ "`polygen -X 10 $NAME | wc -l`" == "10" ]
        then
-               TYPE="block/html"
+               T1="line"
        else
-               TYPE="block/text"
+               T1="block"
        fi
 
+       NAME=${NAME:2}
+       NAME=${NAME%.grm}
+       TYPE="$T1/$T2"
+
        echo "$NAME $TYPE $TITLE"
 done