#!/bin/sh

#
# Expand ispell affix files into plain word-lists
#

if [ $# -lt 3 ]; then
    echo
    echo "usage: $0 <affixed-word-list> <affix-definitions> <output>"
    echo
    exit 1
fi

src=$1
aff=$2
name=$3
POSTFILTER=$4

buildhash $src $aff ./$name.hash

# Note: tr (i.e. | tr " " "\n") is no longer necessary, but gives nicer result 
# Note: pipe with 'sort -u' to make valid counting

if [ "$POSTFILTER" ]; then
    ispell -d ./$name.hash -e < $src | $POSTFILTER > $name.wl
else
    ispell -d ./$name.hash -e < $src > $name.wl
fi

rm -f ./$name.hash
rm -f $src.cnt
rm -f $src.stat

