Skip to content

Commit

Permalink
VERSION 0.05
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.coderepos.org/share/lang/perl/Lingua-JA-Kana/trunk@38936 d0d07461-0603-4401-acd4-de1884942a52
  • Loading branch information
dankogai committed Jun 10, 2011
1 parent 9b06daa commit 4e7d088
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 8 deletions.
13 changes: 11 additions & 2 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Revision history for Lingua-JA-Kana
#
# $Id: Changes,v 0.4 2009/02/06 01:16:08 dankogai Exp dankogai $
# $Id: Changes,v 0.5 2011/06/10 10:23:43 dankogai Exp dankogai $
#
$Revision: 0.4 $ $Date: 2009/02/06 01:16:08 $
$Revision: 0.5 $ $Date: 2011/06/10 10:23:43 $
+ t/01-RT.t
! Makefile.PL
! lib/Lingua/JA/Kana.pm
Added: hankaku2zenkaku and zenkaku2hankaku
Addressed:
http://rt.cpan.org/Ticket/Display.html?id=39590
http://rt.cpan.org/Ticket/Display.html?id=45402

0.04 2009/02/06 01:16:08
! lib/Lingua/JA/Kana.pm
Addressed:
http://rt.cpan.org/Ticket/Display.html?id=39590
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Makefile.PL
README
lib/Lingua/JA/Kana.pm
t/00-load.t
t/01-RT.t
t/boilerplate.t
t/pod-coverage.t
t/pod.t
3 changes: 2 additions & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# $Id: Makefile.PL,v 0.1 2007/12/08 11:09:30 dankogai Exp $
# $Id: Makefile.PL,v 0.2 2011/06/10 10:23:43 dankogai Exp dankogai $
#
use 5.008001; # needs perl 5.8.1 or better
use strict;
Expand All @@ -14,6 +14,7 @@ WriteMakefile(
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
'Encode' => 2.00,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Lingua-JA-Kana-*' },
Expand Down
42 changes: 37 additions & 5 deletions lib/Lingua/JA/Kana.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use warnings;
use strict;
use utf8;

our $VERSION = sprintf "%d.%02d", q$Revision: 0.4 $ =~ /(\d+)/g;
our $VERSION = sprintf "%d.%02d", q$Revision: 0.5 $ =~ /(\d+)/g;

require Exporter;
use base qw/Exporter/;
Expand All @@ -12,6 +12,7 @@ our @EXPORT = qw(
kata2hira katakana2hiragana
romaji2hiragana romaji2katakana
kana2romaji
hankaku2zenkaku zenkaku2hankaku
);

our $USE_REGEXP_ASSEMBLE = do {
Expand Down Expand Up @@ -108,6 +109,7 @@ our %Romaji2Kata = qw(
ya ヤ yu ユ ye イェ yo ヨ
xya ャ xyu ュ xyo ョ
ra ラ ri リ ru ル re レ ro ロ
rya リャ ryu リュ ryo リョ
la ラ li リ lu ル le レ lo ロ
wa ワ wo ヲ
wi ウィ we ウェ
Expand Down Expand Up @@ -135,13 +137,13 @@ our $Re_Kana2Romaji = $Re_Kana2Hepburn;

sub katakana2hiragana{
my $str = shift;
$str =~ tr/ァ-/ぁ-/;
$str =~ tr/ァ-ンヴ/ぁ-んゔ/;
$str;
}

sub hiragana2katakana{
my $str = shift;
$str =~ tr/ぁ-/ァ-/;
$str =~ tr/ぁ-んゔ/ァ-ンヴ/;
$str;
}

Expand Down Expand Up @@ -190,8 +192,26 @@ if ($0 eq __FILE__){
print kana2romaji("ダンコガイ");
print kana2romaji("マイッタ");
print kana2romaji("シンバシ");
print romaji2hiragana("ryoukai"); # RT#39590
print romaji2hiragana("virama"); # RT#45402
}

use Encode;
use Encode::JP::H2Z;
my $eucjp = Encode::find_encoding('eucjp');
sub hankaku2zenkaku {
my $str = $eucjp->encode(shift);
Encode::JP::H2Z::h2z(\$str);
$eucjp->decode($str);
}

sub zenkaku2hankaku {
my $str = $eucjp->encode(shift);
Encode::JP::H2Z::z2h(\$str);
$eucjp->decode($str);
}


1; # End of Lingua::JA::Kana
__END__
Expand All @@ -201,7 +221,7 @@ Lingua::JA::Kana - Kata-Romaji related utilities
=head1 VERSION
$Id: Kana.pm,v 0.4 2009/02/06 01:16:08 dankogai Exp dankogai $
$Id: Kana.pm,v 0.5 2011/06/10 10:23:43 dankogai Exp dankogai $
=head1 SYNOPSIS
Expand Down Expand Up @@ -277,7 +297,19 @@ Converts all occurance of kana (both katakana and hiragana) to romaji.
my $romaji = kana2romaji($str);
INSTALLATION
=head2 hankaku2zenkaku
Converts all occurance of hankaku to zenkaku.
my $romaji = hankaku2zenkaku($str);
=head2 zenkaku2hankaku
Converts all occurance of zenkaku to hankaku.
my $romaji = zenkaku2hankaku($str);
=head1 INSTALLATION
To install this module, run the following commands:
Expand Down
13 changes: 13 additions & 0 deletions t/01-RT.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!perl -T
#
# $Id: 01-RT.t,v 0.1 2011/06/10 10:23:11 dankogai Exp $
#
use strict;
use warnings;
use Test::More;
use Lingua::JA::Kana;

plan tests => 2;
use utf8;
is romaji2hiragana("ryoukai"), 'りょうかい', 'RT#39590';
is romaji2hiragana("virama"), 'ゔぃらま', 'RT#45402';

0 comments on commit 4e7d088

Please sign in to comment.