gnu-fdl-en-cz.sh: employ Pango formatting
Also add collation fields.
This commit is contained in:
parent
16d6eaf012
commit
de7089d669
|
@ -2,20 +2,28 @@
|
||||||
# GNU/FDL English-Czech dictionary, see https://www.svobodneslovniky.cz/
|
# GNU/FDL English-Czech dictionary, see https://www.svobodneslovniky.cz/
|
||||||
curl -Lo- https://www.svobodneslovniky.cz/data/en-cs.txt.gz | \
|
curl -Lo- https://www.svobodneslovniky.cz/data/en-cs.txt.gz | \
|
||||||
zcat | grep -v ^# | sed 's/\\//g' | perl -CSD -F\\t -le '
|
zcat | grep -v ^# | sed 's/\\//g' | perl -CSD -F\\t -le '
|
||||||
sub e { shift =~ s/\\/\\\\/gr =~ s/\n/\\n/gr =~ s/\t/\\t/gr }
|
sub tabesc { shift =~ s/\\/\\\\/gr =~ s/\n/\\n/gr =~ s/\t/\\t/gr }
|
||||||
sub w {
|
sub w {
|
||||||
open(my $f, "|-", "tabfile gnu-fdl-$_[0]") or die $!;
|
my ($name, $dict, $collation) = @_;
|
||||||
print $f e($k) . "\t" . e(join("\n", @$v))
|
open(my $f, "|-", "tabfile", "--pango", "--collation=$collation",
|
||||||
while ($k, $v) = each %{$_[1]};
|
"--website=https://www.svobodneslovniky.cz",
|
||||||
|
"gnu-fdl-$name") or die $!;
|
||||||
|
print $f tabesc($keyword) . "\t" . tabesc(join("\n", @$defs))
|
||||||
|
while ($keyword, $defs) = each %{$dict};
|
||||||
close($f);
|
close($f);
|
||||||
}
|
}
|
||||||
my ($en, $cz, $notes, $special, $translator) = @F;
|
sub xmlesc { shift =~ s/&/&/gr =~ s/</</gr =~ s/>/>/gr }
|
||||||
if ($cz) {
|
sub entry {
|
||||||
|
my ($definition, $notes) = map {xmlesc($_)} @_;
|
||||||
|
$notes ? "$definition <i>$notes</i>" : $definition;
|
||||||
|
}
|
||||||
|
my ($en, $cs, $notes, $special, $translator) = @F;
|
||||||
|
if ($cs) {
|
||||||
$notes =~ s/\w+:\s?//g; # remove word classes
|
$notes =~ s/\w+:\s?//g; # remove word classes
|
||||||
$notes =~ s/(\w+\.)(?!])/($1)/; # quote "pl."
|
$notes =~ s/(\w+\.)(?!])/($1)/; # quote "pl."
|
||||||
push(@{$encz{$en}}, $notes ? "$cz " . $notes : $cz);
|
push(@{$encs{$en}}, entry($cs, $notes));
|
||||||
push(@{$czen{$cz}}, $notes ? "$en " . $notes : $en);
|
push(@{$csen{$cs}}, entry($en, $notes));
|
||||||
} END {
|
} END {
|
||||||
w("en-cz", \%encz);
|
w("en-cz", \%encs, "en");
|
||||||
w("cz-en", \%czen);
|
w("cz-en", \%csen, "cs");
|
||||||
}'
|
}'
|
||||||
|
|
Loading…
Reference in New Issue