X-Git-Url: https://git.donarmstrong.com/?p=deb_pkgs%2Fscowl.git;a=blobdiff_plain;f=src%2Fmake-words;fp=src%2Fmake-words;h=48216c8052da725dc4e8685e3b0905c201176e75;hp=0000000000000000000000000000000000000000;hb=b13ea8a082364672c6de2b010e558211ff52ec9a;hpb=01534a94130c1f5a3a230cf4fe18365a235ba271 diff --git a/src/make-words b/src/make-words new file mode 100755 index 0000000..48216c8 --- /dev/null +++ b/src/make-words @@ -0,0 +1,102 @@ +#!/bin/bash + +level=$1 +export SCOWL_LEVEL=$1 + +rm -f words.$level* + +shopt -s nullglob + +max_level=`src/get-level max` + +get-list() { + res=`src/get-all-below $level $1` + if [ -n "$res" -a -d debug ]; then + cat $res | src/filter | sort -u > debug/$level.l.$1 + fi + echo $res +} + +cap() { + dsr=$1 + shift + if [ -d debug ]; then + cat | sort -u > debug/$level.$dsr.in + cat debug/$level.$dsr.in | "$@" | sort -u > debug/$level.$dsr.out + comm -23 debug/$level.$dsr.out debug/$level.$dsr.in > debug/$level.+.$dsr + cat debug/$level.$dsr.out + rm debug/$level.$dsr.out debug/$level.$dsr.in + else + "$@" + fi +} + +if [ $level -ne $max_level ] +then + + supplement=`get-list supplement` + add_affixes="`get-list add-affixes`" + add_possessive="`get-list add-possessive`" + + if [ -d debug -a -d l/include/$level ]; then + cat l/include/$level/* | sort -u | comm -12 - working/words.`src/get-level next $level` > debug/$level.l.include + fi + + cat $supplement $add_affixes $add_possessive l/include/$level/* \ + | src/filter \ + > working/words.$level.tmp + cp working/words.$level.tmp working/words.$level.tmp.0 + + if [ -n "$add_affixes" ] && [ $level -le `cat l/add-affixes/max-level` ] + then + #echo "Adding affixes" + cat $add_affixes | src/filter | cap affixes src/add-affixes >> working/words.$level.tmp + fi + + if [ $level -lt 80 ] + then + if [ -n "$add_possessive" ] + then + #echo "Adding possessive" + cat $add_possessive | src/filter | cap possessive src/add-affixes just-possessive >> working/words.$level.tmp + fi + else + #echo "Adding possessive" + cat working/words.$level.tmp \ + | cap possessive src/add-affixes use-some just-possessive \ + > working/words.$level.tmp2 + mv working/words.$level.tmp2 working/words.$level.tmp + fi + + echo -n '' > working/exclude.$level + for l in `cat l/levels-list`; do + if [ $l -ge $level -a -e r/special/exclude.$l ]; then + cat r/special/exclude.$l >> working/exclude.$level + fi + done + sort -u working/exclude.$level -o working/exclude.$level + + cat working/words.$level.tmp \ + | cap other-spellings-1 src/add-other-spellings \ + | cap other-forms src/add-other-forms \ + | cap other-spellings-2 src/add-other-spellings \ + | sort -u \ + | comm -23 - working/exclude.$level \ + | comm -12 - working/words.`src/get-level next $level` \ + > working/words.$level + + #rm working/words.$level.tmp + +else + + if [ -d debug/ ]; then + cp working/all.lst debug/$level.everything + fi + + cat working/all.lst \ + | cap possessive src/add-affixes use-all just-possessive \ + | cap other-spellings src/add-other-spellings \ + | sort -u \ + > working/words.$level + +fi