genslow
1.2 KB
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
#! /usr/bin/perl
# Dostosowanie formatu słownika wymagań rzeczownikowych i przymiotnikowych.
#
# Author: Marcin Woliński
# This file is in the public domain.
use strict;
use locale;
my $srcdict=shift;
$srcdict = 's_rzecz' unless $srcdict;
my (%slownik, %swislownik);
print <<EOS;
% This file has been generated with genslow. Do not modify.
% Modifications should be applied to the file $srcdict instead.\n
%
EOS
open TAB, "<$srcdict" || die;
while (<TAB>) {
if (/^%(?!%)/) {
print;
} elsif (/^%%/) {
} elsif (m/^([^\t %]+)\t([^\t%]*)(?: ?%.*)?\n/) {
my ($lemat, @wyms)=($1, split('\+',$2));
my $key="$lemat";
$slownik{$key}=[$lemat, ()]
unless defined $slownik{$key};
push @{$slownik{$key}->[1]}, [@wyms];
} else {
die "Error in $srcdict w. $.: $_";
}
}
foreach my $verb (sort keys %slownik) {
my ($lemat, $wyms) = @{$slownik{$verb}};
my $entry = "$srcdict($lemat, [".
join(', ',map {"[[".join('], [', @$_)."]]"} @$wyms).
"]).\n";
$swislownik{$entry}=1;
}
print $_
foreach sort keys %swislownik;
print <<EOS;
%%% \x4Cocal Variables:
%%% coding: utf-8
%%% mode: prolog
%%% End:
EOS
### Local Variables:
### coding: utf-8
### mode: perl
### End: