source: src/compdic/compdic-update-fst @ f924e4b

Last change on this file since f924e4b was 555c7f8, checked in by Tomasz Obrebski <to@…>, 12 years ago

dodanie mo�liwo�ci szybkiego uaktualniania s�ownika dla lema

  • Property mode set to 100755
File size: 1.6 KB
Line 
1#! /bin/bash
2
3if [ $# -lt 2 ]
4then
5    echo "Usage:"
6    echo "        compdic-update-fst <dictionary> <difference> <difference> ..."
7    echo "where"
8    echo "    <dictionary> - fst format automaton"
9    echo "    <difference> - diff format file containing paths to be added/removed from dictionary"
10    exit 0
11fi     
12
13tempdir=`mktemp -d /tmp/compdic.XXXXXX`
14
15dict=$1
16shift
17
18dicplus=$tempdir/plus.dic
19fstplus=$tempdir/plus.fst
20dicminus=$tempdir/minus.dic
21fstminus=$tempdir/minus.fst
22
23touch $dicplus
24touch $dicminus
25
26while (($#))
27do
28    echo processing $1 ...
29    cat $1 | egrep '^>' | sed -r 's/^> *//;s/[[:space:]].*$//' | canonize >> $dicplus
30    cat $1 | egrep '^<' | sed -r 's/^< *//;s/[[:space:]].*$//' | canonize >> $dicminus
31    shift
32done
33
34echo updating $dict ...
35
36if (( `cat $dicminus | wc -l` ))
37then
38    tmpfst1=$tempdir/tmp1.fst
39    echo "running compdic-dic-to-fst $dicminus $fstminus"
40    compdic-dic-to-fst $dicminus $fstminus
41    echo "running fstdifference $dict $fstminus | fstdeterminize > $tmpfst1"
42    fstdifference $dict $fstminus > $tmpfst1
43else
44    tmpfst1=$dict
45fi
46
47if (( `cat $dicplus | wc -l` ))
48then
49    tmpfst2=$tempdir/tmp2.fst
50    echo "running compdic-dic-to-fst $dicplus $fstplus"
51    compdic-dic-to-fst $dicplus $fstplus
52    echo "running fstunion $tmpfst1 $fstplus | fstdeterminize | fstminimize > $tmpfst2"
53    fstunion $tmpfst1 $fstplus > $tmpfst2
54else
55    tmpfst2=$tmpfst1
56fi
57
58
59
60echo "running mv ${dict} ${dict}~"
61mv ${dict} ${dict}~
62
63echo "cat ${tmpfst2} | fstrmepsilon | fstdeterminize | fstminimize  > ${dict}"
64cat ${tmpfst2} | fstrmepsilon | fstdeterminize | fstminimize  > ${dict}
65chmod a+r ${dict}
66
67rm -r $tempdir
Note: See TracBrowser for help on using the repository browser.