line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::Ogmios::Config::NLPTools; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
16
|
|
|
16
|
|
101
|
use strict; |
|
16
|
|
|
|
|
25
|
|
|
16
|
|
|
|
|
392
|
|
5
|
16
|
|
|
16
|
|
76
|
use warnings; |
|
16
|
|
|
|
|
148
|
|
|
16
|
|
|
|
|
506
|
|
6
|
|
|
|
|
|
|
|
7
|
16
|
|
|
16
|
|
78
|
use Config::General; |
|
16
|
|
|
|
|
29
|
|
|
16
|
|
|
|
|
712
|
|
8
|
|
|
|
|
|
|
|
9
|
16
|
|
|
16
|
|
14823
|
use Data::Dumper; |
|
16
|
|
|
|
|
175409
|
|
|
16
|
|
|
|
|
28924
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $debug_devel_level = 0; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
15
|
0
|
|
|
|
|
|
my $data_config = shift; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $CG_data_struct; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
warn "New Configuration for NLP tool\n" unless $debug_devel_level < 1; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my $config = { |
22
|
|
|
|
|
|
|
'ConfigFile' => undef, |
23
|
|
|
|
|
|
|
'ConfigData' => undef, |
24
|
|
|
|
|
|
|
'CommandsLanguage' => undef, |
25
|
|
|
|
|
|
|
'ResourcesLanguages' => undef, |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
bless $config, $class; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
if (defined $data_config) { |
32
|
0
|
0
|
|
|
|
|
if (ref($data_config) eq "HASH") { |
33
|
0
|
|
|
|
|
|
$config->setConfigData_fromCGStruct($data_config); |
34
|
|
|
|
|
|
|
} else { |
35
|
0
|
|
|
|
|
|
$config->setConfigData_fromFile($data_config); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
0
|
|
|
|
|
|
return $config; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub wrapper { |
42
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# warn "tool: $self\n"; |
45
|
0
|
0
|
|
|
|
|
$self->getConfigData->{"WRAPPER"} = shift if @_; |
46
|
|
|
|
|
|
|
# warn $self->getConfigData->{"WRAPPER"} . "\n"; |
47
|
0
|
|
|
|
|
|
return($self->getConfigData->{"WRAPPER"}); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub name { |
51
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# warn "tool: $self\n"; |
54
|
0
|
0
|
|
|
|
|
$self->getConfigData->{"NAME"} = shift if @_; |
55
|
|
|
|
|
|
|
# warn $self->getConfigData->{"NAME"} . "\n"; |
56
|
0
|
|
|
|
|
|
return($self->getConfigData->{"NAME"}); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub comments { |
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# warn "tool: $self\n"; |
63
|
0
|
0
|
|
|
|
|
$self->getConfigData->{"COMMENTS"} = shift if @_; |
64
|
|
|
|
|
|
|
# warn $self->getConfigData->{"NAME"} . "\n"; |
65
|
0
|
|
|
|
|
|
return($self->getConfigData->{"COMMENTS"}); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub version { |
69
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# warn "tool: $self\n"; |
72
|
0
|
0
|
|
|
|
|
$self->getConfigData->{"VERSION"} = shift if @_; |
73
|
|
|
|
|
|
|
# warn $self->getConfigData->{"NAME"} . "\n"; |
74
|
0
|
|
|
|
|
|
return($self->getConfigData->{"VERSION"}); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub configuration { |
78
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# warn "tool: $self\n"; |
81
|
0
|
0
|
|
|
|
|
$self->getConfigData->{"CONFIGURATION"} = shift if @_; |
82
|
|
|
|
|
|
|
# warn $self->getConfigData->{"NAME"} . "\n"; |
83
|
0
|
|
|
|
|
|
return($self->getConfigData->{"CONFIGURATION"}); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub commands { |
87
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my $lang = 'EN'; # default language |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
$lang = shift if @_; |
92
|
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
|
$self->configuration->{"COMMANDS"}->{"language=$lang"} = shift if @_; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
return($self->configuration->{"COMMANDS"}->{"language=$lang"}); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub getCommandsLanguages { |
99
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my $language; |
102
|
|
|
|
|
|
|
my %langs; |
103
|
|
|
|
|
|
|
|
104
|
0
|
0
|
|
|
|
|
if (!defined $self->{'CommandsLanguage'}) { |
105
|
0
|
|
|
|
|
|
foreach $language (keys %{$self->configuration->{"COMMANDS"}}) { |
|
0
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
if ($language =~ /language=\"?(?[A-Za-z]+)\"?/) { |
107
|
0
|
|
|
|
|
|
$langs{$+{lang}}++; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
0
|
|
|
|
|
|
$self->{'CommandsLanguage'} = []; |
111
|
0
|
|
|
|
|
|
push @{$self->{'CommandsLanguage'}}, keys %langs; |
|
0
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
} |
113
|
0
|
|
|
|
|
|
return($self->{'CommandsLanguage'}); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub getResourcesLanguages { |
117
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
my $language; |
120
|
|
|
|
|
|
|
my %langs; |
121
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
if (!defined $self->{'ResourcesLanguage'}) { |
123
|
0
|
|
|
|
|
|
foreach $language (keys %{$self->configuration->{"COMMANDS"}}) { |
|
0
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
if ($language =~ /language=\"?(?[A-Za-z]+)\"?/) { |
125
|
0
|
|
|
|
|
|
$langs{$+{lang}}++; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
0
|
|
|
|
|
|
$self->{'ResourcesLanguage'} = []; |
129
|
0
|
|
|
|
|
|
push @{$self->{'ResourcesLanguage'}}, keys %langs; |
|
0
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
} |
131
|
0
|
|
|
|
|
|
return($self->{'ResourcesLanguage'}); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub getLanguages { |
136
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
my %langs; |
139
|
|
|
|
|
|
|
my $lang; |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
foreach $lang (@{$self->getCommandsLanguages}) { |
|
0
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
$langs{$lang}++; |
143
|
|
|
|
|
|
|
} |
144
|
0
|
|
|
|
|
|
foreach $lang (@{$self->getResourcesLanguages}) { |
|
0
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
$langs{$lang}++; |
146
|
|
|
|
|
|
|
} |
147
|
0
|
|
|
|
|
|
return(keys %langs); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub existsLanguage { |
151
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
152
|
0
|
|
|
|
|
|
my $language = shift; |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
my %langs; |
155
|
|
|
|
|
|
|
my $lang; |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
foreach $lang (@{$self->getCommandsLanguages}) { |
|
0
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
$langs{$lang}++; |
159
|
|
|
|
|
|
|
} |
160
|
0
|
|
|
|
|
|
foreach $lang (@{$self->getResourcesLanguages}) { |
|
0
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
$langs{$lang}++; |
162
|
|
|
|
|
|
|
} |
163
|
0
|
|
|
|
|
|
warn $self->name . ": " . join('/', keys %langs) . "\n"; |
164
|
0
|
0
|
|
|
|
|
if (exists $langs{$language}) {warn "\tOK\n"}; |
|
0
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
return(exists $langs{$language}); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub resources { |
170
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
my $lang = 'EN'; # default language |
173
|
|
|
|
|
|
|
|
174
|
0
|
0
|
|
|
|
|
$lang = shift if @_; |
175
|
|
|
|
|
|
|
|
176
|
0
|
0
|
|
|
|
|
$self->configuration->{"RESOURCE"}->{"language=$lang"} = shift if @_; |
177
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
return($self->configuration->{"RESOURCE"}->{"language=$lang"}); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub configFile { |
182
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
my $lang = 'EN'; |
185
|
|
|
|
|
|
|
|
186
|
0
|
0
|
|
|
|
|
$lang = shift if @_; |
187
|
|
|
|
|
|
|
|
188
|
0
|
0
|
|
|
|
|
$self->configuration->{"CONFIG"}->{"language=$lang"} = shift if @_; |
189
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
|
return($self->configuration->{"CONFIG"}->{"language=$lang"}); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub getVars { |
195
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
196
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
my $var; |
198
|
0
|
|
|
|
|
|
my %reservedFields = ('CONFIG' => 1, 'COMMANDS' => 1, 'RESOURCE' => 1); |
199
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
foreach $var (keys %{$self->configuration}) { |
|
0
|
|
|
|
|
|
|
201
|
0
|
0
|
|
|
|
|
if (!exists $reservedFields{$var}) { |
202
|
0
|
|
|
|
|
|
warn "\t\t$var: " . $self->configuration->{$var} . "\n"; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub getConfigData { |
208
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
209
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
return($self->{"ConfigData"}); |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub setConfigData_fromFile { |
214
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
215
|
0
|
|
|
|
|
|
my $rcfile = shift; |
216
|
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
my $conf = new Config::General('-ConfigFile' => $rcfile, |
218
|
|
|
|
|
|
|
'-InterPolateVars' => 1, |
219
|
|
|
|
|
|
|
'-InterPolateEnv' => 1 |
220
|
|
|
|
|
|
|
); |
221
|
|
|
|
|
|
|
|
222
|
0
|
|
|
|
|
|
my %config = $conf->getall; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# warn Dumper \%config; |
225
|
|
|
|
|
|
|
|
226
|
0
|
|
|
|
|
|
$self->{'ConfigFile'} = $rcfile; |
227
|
|
|
|
|
|
|
|
228
|
0
|
|
|
|
|
|
$self->{'ConfigData'} = $config{'TOOL'}; |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub setConfigData_fromCGStruct { |
234
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
235
|
|
|
|
|
|
|
|
236
|
0
|
|
|
|
|
|
$self->{"ConfigData"} = shift; |
237
|
|
|
|
|
|
|
|
238
|
0
|
|
|
|
|
|
$self->{"ConfigFile"} = "internal"; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub print { |
242
|
0
|
|
|
0
|
0
|
|
my ($self, $language) = @_; |
243
|
0
|
|
|
|
|
|
my $lang; |
244
|
|
|
|
|
|
|
|
245
|
0
|
|
|
|
|
|
my @langs = ("EN", "FR"); |
246
|
|
|
|
|
|
|
|
247
|
0
|
0
|
|
|
|
|
if (defined $language) { |
248
|
0
|
|
|
|
|
|
@langs = ($language); |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
# if (defined $self->getNLPTools) { |
252
|
|
|
|
|
|
|
# my %nlptools_vars = (); |
253
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
print STDERR " Section NLP tool " . $self->name . "\n"; |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
# print STDERR Dumper $self->getConfigData; |
257
|
0
|
|
|
|
|
|
warn "\tNAME: " . $self->name . "\n"; |
258
|
0
|
|
|
|
|
|
warn "\tVERSION: " . $self->version . "\n"; |
259
|
0
|
|
|
|
|
|
warn "\tDESCRIPTION: " . $self->comments . "\n"; |
260
|
0
|
|
|
|
|
|
warn "\tWRAPPER: " . $self->wrapper . "\n"; |
261
|
0
|
|
|
|
|
|
foreach $lang (@langs) { |
262
|
0
|
|
|
|
|
|
warn "\tCONFIGURATION ($lang): \n"; |
263
|
0
|
|
|
|
|
|
warn "\t COMMANDS: \n"; |
264
|
0
|
|
|
|
|
|
$self->_printVars($self->commands($lang)); |
265
|
0
|
|
|
|
|
|
warn "\t CONFIG: \n"; |
266
|
0
|
|
|
|
|
|
$self->_printVars($self->configFile($lang)); |
267
|
0
|
|
|
|
|
|
warn "\t VARIABLES: \n"; |
268
|
0
|
|
|
|
|
|
$self->getVars($lang); |
269
|
0
|
|
|
|
|
|
warn "\tRESOURCE ($lang): \n"; |
270
|
0
|
|
|
|
|
|
$self->_printVars($self->resources($lang)); |
271
|
|
|
|
|
|
|
} |
272
|
0
|
|
|
|
|
|
warn "\tComments: " . $self->comments . "\n"; |
273
|
0
|
|
|
|
|
|
print STDERR "\n\n"; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
sub printDOT { |
277
|
0
|
|
|
0
|
0
|
|
my ($self, $language) = @_; |
278
|
0
|
|
|
|
|
|
my $lang; |
279
|
|
|
|
|
|
|
|
280
|
0
|
|
|
|
|
|
my @langs = ("EN", "FR"); |
281
|
|
|
|
|
|
|
|
282
|
0
|
0
|
|
|
|
|
if (defined $language) { |
283
|
0
|
|
|
|
|
|
@langs = ($language); |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
# if (defined $self->getNLPTools) { |
287
|
|
|
|
|
|
|
# my %nlptools_vars = (); |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
#print STDERR " Section NLP tool " . $self->name . "\n"; |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
# print STDERR Dumper $self->getConfigData; |
292
|
|
|
|
|
|
|
# warn "lang: $language\n"; |
293
|
0
|
0
|
0
|
|
|
|
if ((!defined $language) || ($self->existsLanguage(uc($language)))) { |
294
|
|
|
|
|
|
|
# warn "\tok\n"; |
295
|
0
|
|
|
|
|
|
my $name = $self->name; |
296
|
0
|
|
|
|
|
|
$name =~ s/ /_/g; |
297
|
0
|
|
|
|
|
|
print "\t$name [label=\"" . $self->comments . " (" . join("/", $self->getLanguages) . ")\"]\n"; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
# warn "\tNAME: " . $self->name . "\n"; |
300
|
|
|
|
|
|
|
# warn "\tVERSION: " . $self->version . "\n"; |
301
|
|
|
|
|
|
|
# warn "\tDESCRIPTION: " . $self->comments . "\n"; |
302
|
|
|
|
|
|
|
# warn "\tWRAPPER: " . $self->wrapper . "\n"; |
303
|
|
|
|
|
|
|
# foreach $lang (@langs) { |
304
|
|
|
|
|
|
|
# warn "\tCONFIGURATION ($lang): \n"; |
305
|
|
|
|
|
|
|
# warn "\t COMMANDS: \n"; |
306
|
|
|
|
|
|
|
# $self->_printVars($self->commands($lang)); |
307
|
|
|
|
|
|
|
# warn "\t CONFIG: \n"; |
308
|
|
|
|
|
|
|
# $self->_printVars($self->configFile($lang)); |
309
|
|
|
|
|
|
|
# warn "\t VARIABLES: \n"; |
310
|
|
|
|
|
|
|
# $self->getVars($lang); |
311
|
|
|
|
|
|
|
# warn "\tRESOURCE ($lang): \n"; |
312
|
|
|
|
|
|
|
# $self->_printVars($self->resources($lang)); |
313
|
|
|
|
|
|
|
# } |
314
|
|
|
|
|
|
|
# warn "\tComments: " . $self->comments . "\n"; |
315
|
|
|
|
|
|
|
#print STDERR "\n\n"; |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
sub _printVars { |
319
|
0
|
|
|
0
|
|
|
my ($self) = shift; |
320
|
0
|
|
|
|
|
|
my $vars = shift; |
321
|
|
|
|
|
|
|
|
322
|
0
|
|
|
|
|
|
my $var; |
323
|
|
|
|
|
|
|
|
324
|
0
|
|
|
|
|
|
foreach $var (keys %$vars) { |
325
|
0
|
|
|
|
|
|
print STDERR "\t\t$var: "; |
326
|
0
|
|
|
|
|
|
warn $vars->{$var} . "\n"; |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
1; |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
__END__ |