-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeppattern.sh
executable file
·116 lines (85 loc) · 2.9 KB
/
deppattern.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
#shopt -s extglob
###################################################################
# Script para facilitar o uso dos parser gerados polo compilador compi-beta.
# - - A variábel DEPPATTERN_DIR estabelece o PATH dos programas.
# - - O sistema inclui o PoS tagger CitiusTools
#
# Pablo Gamallo
# Grupo ProLNat@GE
###################################################################
############################
# Config
############################
DEPPATTERN_DIR="./DepPattern"
PROGS=$DEPPATTERN_DIR"/scripts"
DIRPARSER=$DEPPATTERN_DIR"/parsers"
############################
# Functions
############################
help()
{
echo "Syntax: deppattern.sh <type_of_output> <lang> <file> [parser] [grammar]
type_of_output= -a (dependency analysis), -fa (full dependency analysis) -c (correct tagged text)
language=gl, es, en, pt, metaromance
file=path of the file input
parser=path of the parser, or name of the parser generated from grammar (i.e. metaromance)
grammar=path of the file grammar
"
exit
}
# Parámetros obrigatorios
[ $# -lt 3 ] && help
FLAG=$1
LING=$2
FILE=$3
# Parámetros opcionais
GRAMMAR=""
PARSER="user_parser" #por defeito
[ "$4" != "" ] && PARSER=$4
[ "$5" != "" ] && GRAMMAR=$5
SENT=./CitiusTools/$LING"/sentences-"$LING"_exe.perl"
TOK=./CitiusTools/$LING"/tokens-"$LING"_exe.perl"
SPLIT=./CitiusTools/$LING"/splitter-"$LING"_exe.perl"
NER=./CitiusTools/$LING"/ner-"$LING"_exe.perl"
TAGGER=./CitiusTools/$LING"/tagger-"$LING"_exe.perl"
#NEC=$LING"/nec-"$LING"_exe.perl"
if [ "$FLAG" != "-a" ] && [ "$FLAG" != "-c" ] && [ "$FLAG" != "-fa" ] ; then
help;
echo "help" ;
fi
case $LING in
es) ;;
en) ;;
gl) ;;
pt) ;;
# fr) ;;
*) help
esac
#echo "$FLAG $TAGGER - $LING - $FILE - $GRAMMAR - $PARSER"
##Lançar o Compi se houver gramática
if [ "$GRAMMAR" != "" ]; then
ruby compi-beta.rb $GRAMMAR $PARSER ;
NAMEPARSER="./$PARSER"
#Lançar o parser MetaRomance no caso de nao houver gramatica e fosse especificado
elif [ "$GRAMMAR" == "" ] && [ "$PARSER" == "metaromance" ]; then
NAMEPARSER="$DIRPARSER/parserDefault-metaromance"
#Lançar o parser especificado no caso de nao houver gramatica
elif [ "$GRAMMAR" == "" ] && [ "$PARSER" != "user_parser" ]; then
NAMEPARSER="./$PARSER"
NAMEPARSER=`echo $NAMEPARSER | sed "s/.perl$//" | sed "s/^\.\/\//\//"`
# Lançar o parser por defeito
else
NAMEPARSER="$DIRPARSER/parserDefault-$LING"
NAMEPARSER=`echo $NAMEPARSER | sed "s/.perl$//"`
fi
FILTER="$PROGS/AdapterFreeling-${LING}.perl"
#NAMEFILE=`basename $FILE`;
ZIP=`echo $FILE |awk '($0 ~ /(gz$|zip$)/) {print "zip"}'`
if [ "$ZIP" == "zip" ] ; then
zcat $FILE |tr -d '\015' | $SENT | $TOK | $SPLIT | $NER | $TAGGER |
$FILTER | $NAMEPARSER.perl $FLAG ;
else
cat $FILE |tr -d '\015' | $SENT | $TOK | $SPLIT | $NER | $TAGGER |
$FILTER | $NAMEPARSER.perl $FLAG ;
fi