X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Fmake-words;h=48216c8052da725dc4e8685e3b0905c201176e75;hb=8ace84503eae30ad101165a9bf4c96ac1c87f9b1;hp=fe3cfb76925744307ea36c63f13bbd39ddfdf2c1;hpb=fcd1b19126a5a5f7312c0d789c832742623fa5bd;p=deb_pkgs%2Fscowl.git diff --git a/src/make-words b/src/make-words index fe3cfb7..48216c8 100755 --- a/src/make-words +++ b/src/make-words @@ -1,46 +1,102 @@ #!/bin/bash -rm -f words.$1* +level=$1 +export SCOWL_LEVEL=$1 + +rm -f words.$level* shopt -s nullglob max_level=`src/get-level max` -if [ $1 -ne $max_level ] +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 - add_affixes="`src/get-all-below $1 add-affixes`" + 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 - cat `src/get-all-below $1 supplement` $add_affixes l/include/$1/* \ - | src/filter | sort | uniq > working/words.$1.tmp + 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 [ -n "$add_affixes" ] && [ $1 -le `cat l/add-affixes/max-level` ] + if [ $level -lt 80 ] then - echo "Adding affixes" - cat $add_affixes | src/add-affixes >> working/words.$1.tmp + 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 - src/add-possessive working/words.$1.tmp + 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.$1.tmp \ - | src/filter \ - | src/add-other-spellings \ - | src/add-other-forms \ - | src/add-other-spellings \ + 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 -12 - working/words.`src/get-level next $1` \ - > working/words.$1 + | comm -23 - working/exclude.$level \ + | comm -12 - working/words.`src/get-level next $level` \ + > working/words.$level - rm working/words.$1.tmp + #rm working/words.$level.tmp else + if [ -d debug/ ]; then + cp working/all.lst debug/$level.everything + fi + cat working/all.lst \ - | src/add-possessive \ - | src/add-other-spellings \ + | cap possessive src/add-affixes use-all just-possessive \ + | cap other-spellings src/add-other-spellings \ | sort -u \ - > working/words.$1 + > working/words.$level fi - -