forked from inariksit/ACE-in-GF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-pgf.bash
executable file
·76 lines (59 loc) · 2.2 KB
/
make-pgf.bash
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
#!/bin/bash
# Builds the PGF file from the given source files.
#
# There are two optional arguments:
#
# 1. directory that contains the grammar implementation
# 2. file list pattern (must be in quotes),
# referencing the vocabulary files in multiple languages
#
# Usage examples:
#
# bash make-pgf.bash grammars/acewiki_aceowl/ "words/ontograph_40/TestAttempto{Ace,}.gf"
# ACE RG files
ace="lib/src/ace/"
api="lib/src/api/"
# Full ACE grammar
grammar_ace="grammars/ace/"
grammar_acewiki_aceowl="grammars/acewiki_aceowl/"
# Clex lexicon (ACE-only)
words="words/clex/ClexAce.gf"
if [ $# -eq 2 ]
then
grammar=$1
words=$2
fi
path="present:${grammar_ace}:${grammar_acewiki_aceowl}:${words}:${ace}:${api}"
stack_size="K100M"
build=build
# GF does not like dots in the filename,
# so we use underscores.
name="ACE-0_0_2"
# Start category of the grammar.
# This is explicitly provided for the PGF-compiler in order
# not to rely on the guessing of it, which in some cases
# seems to fail.
startcat="ACEText"
# Do not edit from here on
dir_gr=${build}/gr/
dir_jsgf=${build}/jsgf/
echo "Making output directories (if needed)"
mkdir -p ${dir_gr}
mkdir -p ${dir_jsgf}
echo "Building PGF from:"
eval echo ${words}
# TODO: for some reason the output-dir parameter has no influence,
# so we don't use it, and the PGF is dropped into the current directory.
# Note: optimize-pgf seems to give much better performance,
# startcat is needed to make sure that the PGF compiler finds the start cat.
gf +RTS -${stack_size} -RTS --preproc=mkPresent --make --startcat=${startcat} --optimize-pgf --name $name --path $path `eval echo ${words}`
# Commented out because always creates empty output.
# It would be cool though to find out some day if ACE can be converted into a
# speech recognition grammar.
#echo "Generating JSGF into ${dir_jsgf} ...";
#gf --make --output-format=jsgf --name ${name} --output-dir ${dir_jsgf} ${name}.pgf
# Commented out because takes too long or loops.
# Random generation should have its own test script anyway.
#echo "Generating random examples into ${dir_gr} ... (press Ctrl-C if it takes too long)";
#echo "gr -cat=Text -number=1000 -depth=10 | l -treebank -bind" | gf --run ${name}.pgf > ${dir_gr}/${name}.txt
echo "done."