-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy path40.extract.sh
executable file
·45 lines (38 loc) · 1.12 KB
/
40.extract.sh
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
#!/bin/bash
# vim: ts=4 noexpandtab sw=4 sts=4
cd $(dirname $0)
OUTFILE="$1"
if test -z "$OUTFILE"; then
echo "Usage: $0 <grand morpheme extract file>"
exit 1
fi
MORPHDIR="tmp/m"
mkdir -p "$MORPHDIR"
LOGFILE="logs/extract.log"
rm -f $LOGFILE
TOTAL=
COUNT=0
export COUNT TOTAL
while read INFILE
do
if test -z "$TOTAL"; then
TOTAL=$INFILE
continue
fi
let COUNT++
MORPHFILE=${INFILE/corpus-utf8/$MORPHDIR}
MORPHFILE=${MORPHFILE%.txt}.morph.txt
if test "$INFILE" -nt "$MORPHFILE"; then
./41.extract.py $INFILE $MORPHFILE.tmp 2>> $LOGFILE || { echo "Check $LOGFILE"; exit 1; }
./42.jamo-conv.py $MORPHFILE.tmp $MORPHFILE 2>> $LOGFILE || { echo "Check $LOGFILE"; exit 1; }
rm -f $MORPHFILE.tmp
else
echo "($COUNT/$TOTAL) Skip extract morpheme $INFILE >> $MORPHFILE"
fi
done <<EOT
$(find corpus-utf8 \( -name '?CT_*.txt' -o -name '?T*.txt' \) | wc -l)
$(find corpus-utf8 \( -name '?CT_*.txt' -o -name '?T*.txt' \))
EOT
echo "Concatenate tmp/m/*.morph.txt > $OUTFILE"
find tmp/m -name '*.morph.txt' -exec cat {} \; > $OUTFILE 2>>$LOGFILE
echo "Log file: $LOGFILE"