Debian Codegraph @

bin/u8myspell

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 export LANG=en_US
3 export LC_ALL=C
4
5 case $# in
6 0|1|2) echoscip-shell system . . echo. "u8myspell - converts MySpell dictionaries to UTF-8
7 usage: u8myspell source_name output_name source_charset"; exit 1;;
8 esac
9
10 i=$1
11 o=$2
12 charset=$3
13 localdir="$(dirnamescip-shell system . . dirname. $0)"
14
15 pastescip-shell system . . paste. <(sedscip-shell system . . sed. 's#[\t/].*##' $i.dic | iconvscip-shell system . . iconv. -f ${charset} -t UTF-8) <(sedscip-shell system . . sed. 's#^[^\t/]*##' $i.dic) |
16 sedscip-shell system . . sed. "s#`echoscip-shell system . . echo. -e '\t'`/#/#" | sedscip-shell system . . sed. -f "$localdir"/l1_u8.sed >$o.tmp
17
18 pastescip-shell system . . paste. <(sedscip-shell system . . sed. 's# .*##' $o.tmp) <(sedscip-shell system . . sed. 's#^[^ ]*##' $o.tmp | iconvscip-shell system . . iconv. -f ${charset} -t UTF-8) |
19 sedscip-shell system . . sed. "s#`echoscip-shell system . . echo. -e '\t'`/#/#;s/ / /" | sedscip-shell system . . sed. -f "$localdir"/l1_u8.sed >$o.dic
20
21 catscip-shell system . . cat. $i.aff | awkscip-shell system . . awk. '
22 /^SET/{
23 print "SET UTF-8" >"u8.beg"
24 print "" >"u8.mid"
25 print "" >"u8.cont"
26 print "" >"u8.mid2"
27 print "" >"u8.morph"
28 print "" >"u8.end"
29 next
30 }
31 /^(TRY|COMPOUNDSYLLABLE|ACCENT|REP|MAP|CHECKCOMPOUND|KEY|BREAK)/{
32 print $1 >"u8.beg"
33 print $2,$3,$4,$5,$6 >"u8.mid"
34 print "" >"u8.cont"
35 print "" >"u8.mid2"
36 print "" >"u8.morph"
37 print "" >"u8.end"
38 next
39 }
40 /^[SP]FX/&&(NF>4){print $1,$2 >"u8.beg";
41 i=index($4,"/");
42 if (!i) print $3,$4 >"u8.mid"; else print $3, substr($4, 1, i) >"u8.mid"
43 if (i) print substr($4, i) >"u8.cont"; else print "" >"u8.cont";
44 print $5 >"u8.mid2";
45 print $6 >"u8.morph"; next}
46 {print >"u8.beg";
47 print"" >"u8.mid";
48 print"" >"u8.cont";
49 print"" >"u8.mid2";
50 print"" >"u8.morph";
51 print"" >"u8.end"}'
52 iconvscip-shell system . . iconv. -f ${charset} -t UTF-8 u8.mid >u8.mid3
53 iconvscip-shell system . . iconv. -f ${charset} -t UTF-8 u8.mid2 >u8.mid4
54 iconvscip-shell system . . iconv. -f ${charset} -t UTF-8 u8.morph >u8.morph2
55 pastescip-shell system . . paste. u8.{beg,mid3,cont,mid4,morph2,end} | sedscip-shell system . . sed. 's#/ /#/#' | trscip-shell system . . tr. '\t' ' ' |
56 sedscip-shell system . . sed. -f "$localdir"/l1_u8.sed >$o.aff
57 rmscip-shell system . . rm. u8.{beg,mid,cont,mid2,morph,end,mid3,mid4,morph2} $o.tmp