16 |
require WAIT; |
require WAIT; |
17 |
use strict; |
use strict; |
18 |
use Carp; |
use Carp; |
19 |
use vars qw($VERSION @ISA @EXPORT_OK %STOP $SPLIT $AUTOLOAD); |
use vars qw($VERSION @ISA @EXPORT_OK %STOP $SPLIT $UNAC $ICONV $AUTOLOAD); |
20 |
use subs qw(grundform); |
use subs qw(grundform); |
21 |
|
|
22 |
|
use Text::Unaccent; |
23 |
|
use Text::Iconv; |
24 |
|
|
25 |
require Exporter; |
require Exporter; |
26 |
|
|
27 |
@ISA = qw(Exporter); |
@ISA = qw(Exporter); |
50 |
} |
} |
51 |
]; |
]; |
52 |
|
|
53 |
|
$UNAC = q[ |
54 |
|
sub unac_CHARSET { |
55 |
|
map split(' ',unac_string('CHARSET', $_) || $_), @_; |
56 |
|
} |
57 |
|
]; |
58 |
|
|
59 |
|
my $iconv; |
60 |
|
|
61 |
|
$ICONV = q[ |
62 |
|
sub iconv_CHARSETfrom_CHARSETto { |
63 |
|
my $ic = $iconv->{'CHARSETfrom_CHARSETto'}); |
64 |
|
$ic ||= $iconv->{'CHARSETfrom_CHARSETto'} = Text::Iconv->new('CHARSETfrom','CHARSETto'); |
65 |
|
map split(' ',$ic->convert($_) || $_), @_; |
66 |
|
} |
67 |
|
]; |
68 |
|
|
69 |
|
|
70 |
sub AUTOLOAD { |
sub AUTOLOAD { |
71 |
my $func = $AUTOLOAD; $func =~ s/.*:://; |
my $func = $AUTOLOAD; $func =~ s/.*:://; |
72 |
|
|
93 |
goto \&date; |
goto \&date; |
94 |
} elsif ($func eq 'decode_entities') { |
} elsif ($func eq 'decode_entities') { |
95 |
eval {require HTML::Entities;}; |
eval {require HTML::Entities;}; |
96 |
croak "You must have HTML::Entities to use 'date'" |
croak "You must have HTML::Entities to use 'decode_entities'" |
97 |
if $@ ne ''; |
if $@ ne ''; |
98 |
*decode_entities = HTML::Entities->can('decode_entities'); |
*decode_entities = HTML::Entities->can('decode_entities'); |
99 |
goto &decode_entities; |
goto &decode_entities; |
107 |
$s; |
$s; |
108 |
}; |
}; |
109 |
goto \&$func; |
goto \&$func; |
110 |
|
} elsif ($func =~ /unac_(.+)/) { |
111 |
|
my $charset = $1; |
112 |
|
my $unac = $UNAC; |
113 |
|
$unac =~ s/CHARSET/$charset/g; |
114 |
|
print "### $unac ###\n"; |
115 |
|
eval $unac; |
116 |
|
if ($@ eq '') { |
117 |
|
goto &$func; |
118 |
|
} |
119 |
|
} elsif ($func =~ /iconv_([^_]+)_([^_]+)/) { |
120 |
|
my ($cf,$ct) = ($1,$2); |
121 |
|
my $iconv = $ICONV; |
122 |
|
print "### $cf -> $ct\n"; |
123 |
|
$iconv =~ s/CHARSETfrom/$cf/gs; |
124 |
|
$iconv =~ s/CHARSETto/$ct/gs; |
125 |
|
print "### $iconv ###\n"; |
126 |
|
eval $iconv; |
127 |
|
if ($@ eq '') { |
128 |
|
goto &$func; |
129 |
|
} |
130 |
} |
} |
131 |
Carp::confess "Class WAIT::Filter::$func not found"; |
Carp::confess "Class WAIT::Filter::$func not found"; |
132 |
} |
} |