-
Notifications
You must be signed in to change notification settings - Fork 22
/
lexicon_compiler.perl
executable file
·107 lines (89 loc) · 2.82 KB
/
lexicon_compiler.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
#!/usr/bin/env perl
use strict;
use warnings;
use File::Basename;
$| = 1;
if (!eval{require Storable;}){
warn "Please install Storable module: cpan Storable\n";
exit(1);
}
my $path = dirname(__FILE__);
my $lexicon = {
"gl" => \&compile_gl,
"pt" => \&compile_pt,
"es" => \&compile_es,
"en" => \&compile_en,
"histgz" => \&compile_histgz,
};
my @langs = keys(%{$lexicon});
if($#ARGV >= 0)
{
@langs = @ARGV;
}
print ("Compiling lexicons:\n");
foreach my $lang (@langs)
{
if(!exists($lexicon->{$lang}))
{
print "\tSkipping $lang: language does not exist or is unsupported.\n";
next;
}
$lexicon->{$lang}->();
}
print ("Installation done!\n");
#---------------------------------------functions-----------------------------------#
sub compile_en
{
my $lex = "$path/tagger/en/store_lex.perl";
my $lex_stored = "$path/tagger/en/lexicon/lex_stored";
if(-e $lex_stored) { unlink $lex_stored or die "Could not delete $lex_stored: $!"; }
print ("\tEnglish \t");
do $lex;
print ((-e $lex) ? "Done\n": "Failed\n");
}
sub compile_pt
{
my $lex = "$path/tagger/pt/store_lex.perl";
my $lex_stored = "$path/tagger/pt/lexicon/lex_stored";
if(-e $lex_stored) { unlink $lex_stored or die "Could not delete $lex_stored: $!"; }
print ("\tPortuguese\t");
do $lex;
print ((-e $lex) ? "Done\n": "Failed\n");
}
sub compile_es
{
my $lex = "$path/tagger/es/store_lex.perl";
my $lex_stored = "$path/tagger/es/lexicon/lex_stored";
if(-e $lex_stored) { unlink $lex_stored or die "Could not delete $lex_stored: $!"; }
print ("\tSpanish \t");
do $lex;
print ((-e $lex) ? "Done\n": "Failed\n");
}
sub compile_gl
{
my $lex = "$path/tagger/gl/store_lex.perl";
my $lex_stored = "$path/tagger/gl/lexicon/lex_stored";
my $split_stored = "$path/tagger/gl/lexicon/split_stored";
if(-e $lex_stored) { unlink $lex_stored or die "Could not delete $lex_stored: $!"; }
if(-e $split_stored) { unlink $split_stored or die "Could not delete $split_stored: $!"; }
print ("\tGalician \t");
do $lex;
print ((-e $lex) ? "Done ": "Failed ");
$lex = "$path/tagger/gl/store_split.perl";
do $lex;
print ((-e $lex) ? "Done\n": "Failed\n");
}
sub compile_histgz
{
my $lex = "$path/tagger/histgz/store_lex.perl";
my $lex_stored = "$path/tagger/histgz/lexicon/lex_stored";
my $split_stored = "$path/tagger/histgz/lexicon/split_stored";
if(-e $lex_stored) { unlink $lex_stored or die "Could not delete $lex_stored: $!"; }
if(-e $split_stored) { unlink $split_stored or die "Could not delete $split_stored: $!"; }
print ("\tHistoric galician-portuguese \t");
do $lex;
print ((-e $lex) ? "Done ": "Failed ");
$lex = "$path/tagger/histgz/store_split.perl";
do $lex;
print ((-e $lex) ? "Done\n": "Failed\n");
}