-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.perl
118 lines (98 loc) · 3.17 KB
/
make.perl
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
117
118
#/usr/bin/perl
if (@ARGV[0] eq "-trace") {
shift;
$GFCMD = ">&STDOUT";
} else {
$GFCMD = "| gf +RTS -M1000M -K100M";
# $GFCMD = "| gf +RTS -M1000M -K100M | perl -ne 'next if / wrote file |[\+\|] reading /; print \"\n\" if /^- compiling/; print'";
}
die "Usage: perl make.perl domain" unless $#ARGV==0;
$dom = shift;
@langs = ("Eng", "Swe");
@sysmods = ("System", "SystemMM");
@usrmods = ("User");
@multimodal = ($dom);
$javaopts = "";
$nuanceopts = "-preproc=./mkUnimodal";
$dir = $dom;
$cleanPreproc = "rm -f Common/GodisApp.gfc Common/GodisApp.gfr Common/GodisMM.gfc Common/GodisMM.gfr";
if ($dom eq "Agenda") {
$javaopts = $nuanceopts = "-preproc=./mkSingleUnimodal";
@sysmods = ("System");
@multimodal = ();
} elsif ($dom eq "Delux") {
$dir = "DeLux";
push @multimodal, "MP3";
@usrmods = ("MP3");
} elsif ($dom eq "MP3") {
push @multimodal, "Delux";
@usrmods = ("Delux");
} elsif ($dom eq "Tram") {
push @langs, "Ger", "Spa"; # "Ita", "Fre", "Fin";
$javaopts .= " -path=Tram:Common:prelude:present";
$nuanceopts .= " -path=Tram:Common:prelude:present";
} else {
die "Usage: perl make.perl (Agenda|Delux|MP3|Tram)";
}
@concrs = ("Sem", @langs);
@mods = (@sysmods, @usrmods);
$output = "output";
system "mkdir -p $output";
print "**********************************************************************\n";
print "** Current domain: $dom\n\n";
if ($#multimodal >= 0) {
print "** Autogenerating grammars\n";
for $mm (@multimodal) {
print "perl combineMM.perl $mm\n";
system "perl combineMM.perl $mm";
}
}
print "\n\n** Do you want to create (J)ava grammars, (N)uance grammars, or (B)oth?\n";
$answer = <STDIN>;
# java
if ($answer =~ /^\s*[jb]\s*$/i) {
system $cleanPreproc;
open GF, $GFCMD;
for $mod (@mods) {
$base = $dom . $mod;
print GF "e\n";
for $lng (@concrs) {
print GF "i -nocf -optimize=share $javaopts $dir/" .
($mod.$lng eq "SystemMMSem" ? $dom."SystemSem.gf\n" : "$base$lng.gf\n");
}
print GF "s\n";
print GF "pm -utf8 -utf8id -printer=header | wf $output/$base.gfcm\n";
print GF "pm -utf8 -utf8id -printer=cfgm | wf $output/$base.cfgm\n";
open PROP, "> $output/$base.properties\n";
print PROP <<XXX;
name: $base
gfcm: $base.gfcm
cfgm: $base.cfgm
unlexer = se.chalmers.cs.gf.linearize.unlex.TextUnlexer
XXX
}
close GF;
print "\n\n** Java grammars created:\n";
print " $output/$dom\{" . join(",",@mods) . "\}.\{gfcm,cfgm,properties\}\n\n";
print "**********************************************************************\n";
}
# nuance
if ($answer =~ /^\s*[nb]\s*$/i) {
system $cleanPreproc;
open GF, $GFCMD;
for $mod (@usrmods) {
print GF "e\n";
for $lng (@langs) {
$base = $dom . $mod . $lng;
print GF "i -nocf -optimize=share $nuanceopts $dir/$base.gf\n";
print GF "s\n";
print GF "pg -lang=$base -printer=gsl | wf $output/$base.gsl\n";
}
}
close GF;
print "\n\n** Nuance grammars created:\n";
print " $output/$dom\{" . join(",",@usrmods) . "\}\{" . join(",",@langs) ."\}.gsl\n\n";
print "**********************************************************************\n";
}
system $cleanPreproc;
print "\n\nThank you for using this script.\n";