Lingua-JA-Romanize-Japanese
view release on metacpan or search on metacpan
lib/Lingua/JA/Romanize/DictJA.pm view on Meta::CPAN
Cached dictionary files:
@INC / Lingua/JA/Romanize/Japanese.store
The DictJA module is called only from Makefile.PL
on installing this package.
=head1 REQUIRED MODULES
L<DB_File> module is required to create cached dictionary files.
L<Jcode> module is required on Perl 5.8.0 or less to install
this package. L<Encode> module is used on Perl 5.8.1 or above.
L<LWP::UserAgent> module is optional and used to fetch external
dictionary files.
L<IO::Zlib> module is optional and used to parse gzipped files.
=head1 SEE ALSO
L<Lingua::JA::Romanize::Japanese>
=head1 COPYRIGHT AND LICENSE
Copyright (c) 2006-2008 Yusuke Kawasaki. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=cut
# ----------------------------------------------------------------
package Lingua::JA::Romanize::DictJA;
use strict;
use vars qw( $VERSION );
$VERSION = "0.23";
use Lingua::JA::Romanize::Kana;
use ExtUtils::MakeMaker;
use Fcntl;
use IO::File;
my $PERL581 = 1 if ( $] >= 5.008001 );
my $FETCH_CACHE = "skk";
my $DICT_DB = 'Japanese.bdb';
my $DIC_SMALL = [ qw(
skk/SKK-JISYO.S
) ];
my $DIC_LARGE = [ qw(
http://openlab.jp/skk/skk/dic/SKK-JISYO.L
http://openlab.jp/skk/skk/dic/SKK-JISYO.jinmei
http://openlab.jp/skk/skk/dic/SKK-JISYO.propernoun
http://openlab.jp/skk/skk/dic/SKK-JISYO.geo
http://openlab.jp/skk/skk/dic/SKK-JISYO.station
) ];
my $DIC_GZIPED = [ qw(
http://openlab.jp/skk/dic/SKK-JISYO.L.gz
http://openlab.jp/skk/dic/SKK-JISYO.jinmei.gz
http://openlab.jp/skk/dic/SKK-JISYO.propernoun.gz
http://openlab.jp/skk/dic/SKK-JISYO.geo.gz
http://openlab.jp/skk/dic/SKK-JISYO.station.gz
) ];
# ----------------------------------------------------------------
sub update {
my $package = shift;
my $base = shift;
print "Updater: ", __PACKAGE__, " (", $VERSION, ")\n";
unless ( defined $base ) {
$base = $INC{ join( "/", split( "::", (__PACKAGE__) . ".pm" ) ) };
$base =~ s#/[^/]*$##;
}
local $| = 1;
my $dbpath = $base . "/" . $DICT_DB;
if ( -r $dbpath ) {
print "DB_File is already exist: $dbpath\n";
my $mess = 'Do you wish to overwrite this?';
my $yes = ExtUtils::MakeMaker::prompt( $mess, 'y' );
if ( $yes ne 'y' ) {
print "Canceled to update the dictionary.\n";
return;
}
} else {
print "Path: ", $dbpath, "\n";
}
print "Loading module: DB_File.pm\n";
&require_db_file(); # required
print "Loading module: LWP::UserAgent\n";
&require_lwp_useragent();
print "Loading module: IO::Zlib\n";
&require_io_zlib();
if ($PERL581) {
print "Loading module: Encode.pm\n";
&require_encode(); # Perl 5.8.x
}
else {
print "Loading module: Jcode.pm\n";
&require_jcode(); # Perl 5.005/5.6.x
}
my $diclist = $DIC_SMALL; # default dictionary
print "External dictionaries:\n";
my $cand = defined $IO::Zlib::VERSION ? $DIC_GZIPED : $DIC_LARGE;
print "\t", $_, "\n" foreach (@$cand);
my $mess = 'Do you wish to download these files?';
my $yes = ExtUtils::MakeMaker::prompt( $mess, 'y' );
if ( $yes eq 'y' ) {
$diclist = $cand;
}
else {
print "Okay, the default dictionary is used:\n";
print "\t", $_, "\n" foreach (@$diclist);
}
# load all dictionaries
my $tmphash = {};
foreach my $jisyo (@$diclist) {
( run in 1.540 second using v1.01-cache-2.11-cpan-364913b4093 )