Lingua::Han::Stroke - Retrieve the stroke count of Chinese character.


Lingua-Han-Stroke documentation Contained in the Lingua-Han-Stroke distribution.

Index


Code Index:

NAME

Top

Lingua::Han::Stroke - Retrieve the stroke count of Chinese character.

SYNOPSIS

Top

    use Lingua::Han::Stroke;
    my $stroke = Lingua::Han::Stroke->new();

    print $stroke->stroke("ĪŅ"); # 7

DESCRIPTION

Top

any difficulty? send me email. :)

AUTHOR

Top

Fayland Lam, <fayland at gmail.com>

BUGS

Top

Please report any bugs or feature requests to bug-lingua-han-stroke at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Lingua-Han-Stroke. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Lingua::Han::Stroke

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Lingua-Han-Stroke

* CPAN Ratings

http://cpanratings.perl.org/d/Lingua-Han-Stroke

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Lingua-Han-Stroke

* Search CPAN

http://search.cpan.org/dist/Lingua-Han-Stroke

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Lingua-Han-Stroke documentation Contained in the Lingua-Han-Stroke distribution.

package Lingua::Han::Stroke;

use warnings;
use strict;
use vars qw($VERSION);
$VERSION = '0.07';

use File::Spec;
use Lingua::Han::Utils qw/Unihan_value/;

sub new {
	my $class = shift;
	my $dir = __FILE__; $dir =~ s/\.pm//o;
	-d $dir or die "Directory $dir nonexistent!";
	my $self;
	my %st;
	my $file = File::Spec->catfile($dir, 'Stroke.dat');
	open(FH, $file)	or die "$file: $!";
	while(<FH>) {
		my ($uni, $st) = split(/\s+/);
		$st{$uni} = $st;
	}
	close(FH);
	$self->{'st'} = \%st;
	return bless $self => $class;
}

sub stroke {
	my ($self, $hanzi) = @_;	
	my $code = Unihan_value($hanzi); # got the Unihan field 1
	return $self->{'st'}->{$code};
}
1;
__END__