• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#/bin/sh
2
3# Compare dictionary with original libthai source
4#
5# It takes libthai dict source dir as the argument, then scans all dicts
6# under that dir and try hyphenating them, and finally compares the
7# results with current source.
8#
9# For each dict, the new source is created as *.new, and the diffs as *.diff.
10#
11# Usage diff-dicts.sh {libthai-dict-src-dir}
12
13if [ $# -ne 1 ]; then
14  echo "Usage: diff-dicts.sh {libthai-dict-src-dir}"
15  exit 1
16fi
17
18DICTS=`echo tdict-*.txt`
19DIR=$1
20
21for d in ${DICTS}; do
22
23  cat > odict.tex << EOT
24\\documentclass{article}
25\\usepackage[thai]{babel}
26\\usepackage[utf8x]{inputenc}
27
28\\begin{document}
29EOT
30
31  sed -e 's/.*/\\showhyphens{&}/' ${DIR}/$d >> odict.tex
32
33  cat >> odict.tex << EOT
34\\end{document}
35EOT
36
37  NEWDICT=$d.new
38  pdflatex odict.tex \
39    | iconv -f tis-620 -t utf-8 | grep '^\[\]' | cut -d' ' -f3 > ${NEWDICT}
40
41  diff -u $d ${NEWDICT} > $d.diff
42
43  rm odict.tex odict.aux odict.log
44done
45
46