11 |
use YAML; |
use YAML; |
12 |
use Carp; |
use Carp; |
13 |
use Getopt::Long; |
use Getopt::Long; |
14 |
|
use Text::Unaccent 1.02; |
15 |
|
|
16 |
use lib './lib'; |
use lib './lib'; |
17 |
use WebPAC; |
use WebPAC; |
47 |
}, |
}, |
48 |
}; |
}; |
49 |
|
|
50 |
|
## remove accented characters |
51 |
|
# |
52 |
|
sub unac { |
53 |
|
my $string = shift || return; |
54 |
|
$string = unac_string($code_page,$string); |
55 |
|
$string =~ tr/ðÐ/dD/; |
56 |
|
$string = unac_entities($string); |
57 |
|
return $string; |
58 |
|
} |
59 |
|
sub unac_2 { |
60 |
|
my $string = shift || return; |
61 |
|
if (length($string) > 2) { |
62 |
|
my $pr = substr($string,0,2); |
63 |
|
$string = unac_string($code_page,substr($string,2)); |
64 |
|
$string =~ tr/ðÐ/dD/; |
65 |
|
$string = $pr . $string; |
66 |
|
} |
67 |
|
$string = unac_entities($string); |
68 |
|
return lc($string); |
69 |
|
} |
70 |
|
|
71 |
|
sub unac_entities { |
72 |
|
my $ent = shift || return; |
73 |
|
|
74 |
|
$ent =~ s/&(\w)(acute|cedil|circ|grave|ring|slash|tilde|uml);/$1/gi; |
75 |
|
$ent =~ s/ð/d/g; |
76 |
|
$ent =~ s/&E[tT][hH];/D/g; |
77 |
|
$ent =~ s/&(\w\w)lig;/$1/gi; |
78 |
|
|
79 |
|
return $ent; |
80 |
|
} |
81 |
|
|
82 |
# create WebPAC object |
# create WebPAC object |
83 |
# |
# |
84 |
my $webpac = new WebPAC( |
my $webpac = new WebPAC( |
183 |
#path => $f, |
#path => $f, |
184 |
path => $webpac->mfn, |
path => $webpac->mfn, |
185 |
headline => $h, |
headline => $h, |
186 |
words => $words, |
words => unac($words), |
187 |
); |
); |
188 |
} |
} |
189 |
|
|
195 |
|
|
196 |
foreach my $h (@{$ds->{'index'}}) { |
foreach my $h (@{$ds->{'index'}}) { |
197 |
$thes->{$ds->{'tag'}}->insert( |
$thes->{$ds->{'tag'}}->insert( |
198 |
headline => $h, |
sort_by => unac_2($h), |
199 |
mfn => $webpac->mfn, |
mfn => $webpac->mfn, |
200 |
|
headline => $h, |
201 |
); |
); |
202 |
} |
} |
203 |
} |
} |
235 |
|
|
236 |
} # XXX if(0) |
} # XXX if(0) |
237 |
|
|
238 |
$log->debug("lookup hash: ",Dump($webpac->{'lookup'})); |
#$log->debug("lookup hash: ",Dump($webpac->{'lookup'})); |
239 |
|
|
240 |
$log->info("creating tree"); |
$log->info("creating tree"); |
241 |
|
|
344 |
}); |
}); |
345 |
|
|
346 |
my $tree = new WebPAC::Tree( |
my $tree = new WebPAC::Tree( |
347 |
dir => './out', |
tree => \@tree, |
348 |
html => 'browse.html', |
); |
349 |
|
|
350 |
|
$tree->output( |
351 |
|
dir => './out', |
352 |
|
html => 'browse.html', |
353 |
template => './output_template/tree.tt', |
template => './output_template/tree.tt', |
354 |
js => 'tree-ids.js', |
js => 'tree-ids.js', |
|
tree => \@tree, |
|
355 |
); |
); |
356 |
|
|
357 |
|
$tree->output( |
358 |
|
dir => './eurovoc', |
359 |
|
html => 'hijerarhija.html', |
360 |
|
template => './output_template/hijerarhija.tt', |
361 |
|
js => 'tree-ids.js', |
362 |
|
); |
363 |
|
|
364 |
|
|
365 |
$log->info("closing index"); |
$log->info("closing index"); |
366 |
$index->close; |
$index->close; |
367 |
|
|