File: update-anthy-dics

package info (click to toggle)
anthy 9100h-6
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 17,664 kB
  • ctags: 3,114
  • sloc: ansic: 26,140; sh: 8,551; lisp: 1,264; makefile: 200
file content (95 lines) | stat: -rw-r--r-- 2,014 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh

set -e

CANNADIC='gcanna.ctd gcannaf.ctd gtankan.ctd'
EXTRADIC='adjust.t compound.t extra.t'
EXTRADIC_UTF8='g_fname.t'

DICDIR=/var/lib/anthy
METADICDIR=/usr/share/anthy/dic
DEPGRAPHDIR=/var/lib/anthy/depgraph
WORDDICDIR=/var/lib/anthy/mkworddic
CALCTRANSDIR=/var/lib/anthy/calctrans

CONFIG='/etc/anthy/diclist'
DICTCONFIG='/etc/anthy/dict.args'
TMPDICTCONFIG='/tmp/dict.args.XXXXXX'

OLDDIR=`pwd`
cd $METADICDIR

TMPDICTCONFIG=$(mktemp $TMPDICTCONFIG)
if [ $? != 0 ]; then
	echo "mktemp failed, aborting" 1>&2
	exit 1
fi


echo "set_input_encoding eucjp" >> $TMPDICTCONFIG
for file in $CANNADIC $EXTRADIC
do
  if [ -f $file ]; then
    echo "read $METADICDIR/$file" >> $TMPDICTCONFIG
  fi
done


addondics=$(sort -u $CONFIG| tr '\n' ' '| sed 's/\ $//')
for file in $addondics; do
	if [ -f $file ]; then
		echo "read $METADICDIR/$file" >> $TMPDICTCONFIG
	fi
done


# start adding utf8 dict
echo "set_input_encoding utf8" >> $TMPDICTCONFIG
for utf_dict in $EXTRADIC_UTF8
do
  echo "read $METADICDIR/$utf_dict" >> $TMPDICTCONFIG
done
# end adding utf8 dict

echo "build_reverse_dict" >> $TMPDICTCONFIG
echo "read_uc $METADICDIR/udict" >> $TMPDICTCONFIG
echo "set_dict_encoding utf8" >> $TMPDICTCONFIG
echo "write anthy.wdic" >> $TMPDICTCONFIG
echo "done" >> $TMPDICTCONFIG

echo -n 'Updating anthy.dic...'

rm -rf $WORDDICDIR; mkdir $WORDDICDIR
rm -rf $DEPGRAPHDIR; mkdir $DEPGRAPHDIR
rm -f $CALCTRANSDIR

cp /etc/anthy/anthy-conf /var/lib/anthy

if [ -f $DICDIR/anthy.dic ]; then
	rm -f $DICDIR/anthy.dic
fi

mv $TMPDICTCONFIG $DICTCONFIG

cd $WORDDICDIR
/usr/bin/mkworddic -f $DICTCONFIG > /dev/null 2>&1

cd $DEPGRAPHDIR
for i in /usr/share/anthy/depgraph/*.depword; do
	ln -s $i $DEPGRAPHDIR/`basename $i`
done
ln -sf /usr/share/anthy/depgraph/indepword.txt $DEPGRAPHDIR

ln -sf /usr/share/anthy/depgraph/conjugate.table $DEPGRAPHDIR
/usr/bin/mkdepgraph 

ln -sf /usr/share/anthy/calctrans $CALCTRANSDIR

cd $DICDIR
/usr/bin/mkfiledic -p ./

rm -f /var/lib/anthy/anthy-conf

cd $OLDDIR

echo 'done.'