-
Notifications
You must be signed in to change notification settings - Fork 0
/
view
executable file
·66 lines (62 loc) · 1.34 KB
/
view
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
#!/bin/bash
#
DATA_DIR=/afs/ir/class/cs224n/pa3/data
# -- Variables
#(parse command line)
doc=$1
if [ "$doc" = "" ]; then
echo "usage: `basename $0` [doc_name|doc_index]"
exit 1
fi
#(number or filepath)
isNumber=""
case $doc in
''|*[!0-9]*) ;;
*) isNumber=true ;;
esac
# -- Find Document
#(find document)
if [ $isNumber ]; then
file=`find "$DATA_DIR/conll2011.train.ser/" -name "*.dat" |\
sort |\
sed -n "$doc"p`
else
#(look in train)
files=`find "$DATA_DIR/conll2011.train.ser/" -regex ".*$doc.*.dat"`
for f in $files; do
if [ $file ]; then
echo "Multiple matching files: '$file' and '$f'"
exit 1
fi
file="$f"
done
#(look in dev)
if [ "$file" = "" ]; then
files=`find "$DATA_DIR/conll2011.dev.ser/" -regex ".*$doc.*.dat"`
for f in $files; do
if [ $file ]; then
echo "Multiple matching files: '$file' and '$f'"
exit 1
fi
file="$f"
done
fi
fi
#(error check)
if [ "$file" = "" ]; then
echo "Could not find document: $doc"
exit 1
fi
# -- Render Document
echo "--------------------------------------------------------------------------------"
echo "$file"
echo "--------------------------------------------------------------------------------"
while read line; do
if [ "$line" = '(end gloss)' ]; then
exit 1
elif [ "$line" = "---------gloss--------" ]; then
donothing=true
else
echo "$line"
fi
done < $file