#!/bin/sh --
#	anthy_diff.sh - Anthy user dictionay Diff Script
#	Thu,06 Sep,2007
#	Tue,03 Feb,2009
#	Fri,05 Jun,2009
#	Copyright(C) 2007-2009 G-HAL (fenix.ne.jp)
#

BASENAME=/usr/bin/basename
MKTEMP=/usr/bin/mktemp
tempfoo=`${BASENAME} $0`
TMPDIR=`${MKTEMP} -d /tmp/${tempfoo}.XXXXXX`
if [ $? -ne 0 ]; then
  echo "$0: Can't create temp dir, exiting..."
  exit 1
fi

CAT=/bin/cat
RM=/bin/rm
SORT=/usr/bin/sort
UNIQ=/usr/bin/uniq



diffexist_file () {
  $CAT $1 $2 $2 | $SORT | $UNIQ -u
}

diffexist () {
  echo "--- $1"
  diffexist_file ${FILE1}.anthy.userdic.$1 ${FILE2}.anthy.userdic.$1
}


if [ -z "$1" -o -z "$2" ]; then
  echo "usage> $0 from-file to-file"
  exit 1
fi

if [ ! -r "$1" ]; then
  echo "from-file is not found."
fi
if [ ! -r "$2" ]; then
  echo "to-file is not found."
fi
if [ ! -r "$1" -o ! -r "$2" ]; then
  exit 1
fi


FILE1=`${MKTEMP} $TMPDIR/XXXXXX`.`${BASENAME} $1`
FILE2=`${MKTEMP} $TMPDIR/XXXXXX`.`${BASENAME} $2`
anthy_split.pl ${FILE1} < $1
anthy_split.pl ${FILE2} < $2

diffexist OCHAIRE
diffexist CAND_HISTORY
diffexist PREFIX_HISTORY
diffexist INDEP_HISTORY
diffexist INDEPPAIR
diffexist SUFFIX_HISTORY
diffexist DEP_HISTORY
diffexist UNKNOWN_WORD
diffexist EXPANDPAIR
diffexist PREDICTION

${RM} -PR ${TMPDIR}

# [ End of File ]

