File: test-prefix.sh

package info (click to toggle)
apertium-tur 0.2.0~r83161-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,860 kB
  • sloc: python: 476; sh: 119; makefile: 107; xml: 54
file content (53 lines) | stat: -rw-r--r-- 1,479 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
#!/bin/bash

SED=gsed
which $SED >/dev/null;
if [[ $? -eq 1 ]]; then
	SED="sed";
fi

TMPSCRIPT=`mktemp /tmp/tmp.XXXXXXXXXX`;
echo "import sys;
tag = False;
c = sys.stdin.read(1);
while c != '':
        if c == '<':
                sys.stdout.write('%<');
                tag = True;
                c = sys.stdin.read(1);
        if c == '>':
                sys.stdout.write('%> ');
                tag = False;
                c = sys.stdin.read(1);
                continue;
        if tag:             
                sys.stdout.write(c);
        else:
                sys.stdout.write(c + ' ');
        c = sys.stdin.read(1);
        if c == '\n':
                break;
" > $TMPSCRIPT;

TMPFILTER=`mktemp /tmp/tmp.f.XXXXXXXXXX`;
TMPREGEX=`mktemp /tmp/tmp.r.XXXXXXXXXX`;
TMPOUT1=`mktemp /tmp/tmp.o1.XXXXXXXXXX`;
TMPOUT2=`mktemp /tmp/tmp.o2.XXXXXXXXXX`;
TMPINVERT=`mktemp /tmp/tmp.i.XXXXXXXXXX`;

echo "~[ \$[ %<num%> ] |
 \$ [ %<subst%> ] |
 \$ [ %<neg%> ] |
 \$ [ %<p2%> ] |
 \$ [ %<p3%> ] |
 \$ [ %<qst%> ] 
] ;" | hfst-regexp2fst -S -o $TMPFILTER
printf "$1" | python3.3 $TMPSCRIPT | $SED 's/^/"/g' | $SED 's/$/?*"/g';
echo ""
printf $1 | python3.3 $TMPSCRIPT | $SED 's/$/?*/g' |  hfst-regexp2fst -o $TMPREGEX
hfst-invert .deps/tur.LR.hfst -o $TMPINVERT
hfst-compose-intersect -1 $TMPINVERT -2 $TMPREGEX -o $TMPOUT1
hfst-compose-intersect -1 $TMPOUT1 -2 $TMPFILTER -o $TMPOUT2
hfst-fst2strings $TMPOUT2 

#rm $TMPFILTER $TMPREGEX $TMPOUT1 $TMPOUT2 $TMPINVERT $TMPSCRIPT