.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Kakasi 3pm" .TH Kakasi 3pm 2024-01-10 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Text::Kakasi \- perl frontend to kakasi .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 7 \& use Text::Kakasi; \& # functional \& $res = Text::Kakasi::getopt_argv(\*(Aq\-JJ\*(Aq, \*(Aq\-c\*(Aq, \*(Aq\-w\*(Aq); \& $str = Text::Kakasi::do_kakasi($japanese_text); \& # object\-oriented \& $obj = Text::Kakasi\->new(\*(Aq\-JJ\*(Aq, \*(Aq\-c\*(Aq, \*(Aq\-w\*(Aq); \& $str = $obj\->get($japanese_text); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module provides interface to kakasi (kanji kana simple inverter). kakasi is a set of programs and libraries which does what Japanese input methods do in reverse order. You feed Japanese and kakasi converts it to phonetic representation thereof. kakasi can also be used to tokenizing Japanese text. To find more about kakasi, see . .PP Text::Kakasi now features both functional and object-oriented APIs. functional APIs are 100% compatible with ver. 1.05. But to take advantage of "Perl 5.8 Features", you should use OOP APIs instead. .PP See Text::Kakasi::JP for the Japanese version of this document. .SH "Functional APIs" .IX Header "Functional APIs" Note \f(CW\*(C`Text::Kakasi::\*(C'\fR is omitted. Text::Kakasi does not export these functions by default. You can import these function as follows; .PP .Vb 1 \& use Text::Kakasi qw/getopt_argv do_kakasi/; .Ve .ie n .IP "$err = getopt_argv($arg1, $arg2, ...)" 2 .el .IP "\f(CW$err\fR = getopt_argv($arg1, \f(CW$arg2\fR, ...)" 2 .IX Item "$err = getopt_argv($arg1, $arg2, ...)" initializes kakasi with options options are the same as \f(CW\*(C`kakasi\*(C'\fR command. Here is the summery as of kakasi 2.3.4. .Sp .Vb 6 \& \-a[jE] \-j[aE] \-g[ajE] \-k[ajKH] \& \-E[aj] \-K[ajkH] \-H[ajkK] \-J[ajkKH] \& \-i{oldjis,newjis,dec,euc,sjis} \& \-o{oldjis,newjis,dec,euc,sjis} \& \-r{hepburn,kunrei} \-p \-s \-f \-c"chars" \& [jisyo1, jisyo2,,,] \& \& Character Sets: \& a: ascii j: jisroman g: graphic k: kana \& (j,k defined in jisx0201) \& E: kigou K: katakana H: hiragana J: kanji \& (E,K,H,J defined in jisx0208) \& \& Options: \& \-i: input coding system \-o: output coding system \& \-r: romaji conversion system \& \-p: list all readings (with \-J option) \& \-s: insert separate characters (with \-J option) \& \-f: furigana mode (with \-J option) \& \-c: skip chars within jukugo \& (with \-J option: default TAB CR LF BLANK) \& \-C: romaji Capitalize (with \-Ja or \-Jj option) \& \-U: romaji Upcase (with \-Ja or \-Jj option) \& \-u: call fflush() after 1 character output \& \-w: wakatigaki mode .Ve .Sp Returns 0 on success and nonzero on failure. .Sp Unlike version 1.x where you have to start the first argument with \&\f(CW\*(C`kakasi\*(C'\fR, you can omit that in version 2.x (adding \f(CW\*(C`kakasi\*(C'\fR does not harm so compatibility is preserved). .ie n .IP "$result_str = do_kakasi($str)" 2 .el .IP "\f(CW$result_str\fR = do_kakasi($str)" 2 .IX Item "$result_str = do_kakasi($str)" apply kakasi to \f(CW$str\fR and returns result. If anything goes wrong it return \f(CW\*(C`undef\*(C'\fR. .IP \fBclose_kanwadic()\fR 2 .IX Item "close_kanwadic()" closes dictionary files which are implicitly opened. This function is for backward compatibity only and you should never have to use this function today. .SH "Object-Oriented APIs" .IX Header "Object-Oriented APIs" As of 2.0, Text::Kakasi also offers OOP APIs. .ie n .IP "$k = Text::Kakasi\->new($args ...)" 2 .el .IP "\f(CW$k\fR = Text::Kakasi\->new($args ...)" 2 .IX Item "$k = Text::Kakasi->new($args ...)" Constructs object. When argument is fed, it is the same as \&\f(CW\*(C`Text::Kakasi\->new\->set($args ...)\*(C'\fR .ie n .IP "$k\->set($args ...)" 2 .el .IP "\f(CW$k\fR\->set($args ...)" 2 .IX Item "$k->set($args ...)" OOP interface to \f(CW\*(C`getopt_argv\*(C'\fR. .Sp .Vb 2 \& my $k = Text::Kakasi\->new; \& $k\->set(\*(Aq\-w\*(Aq); # Text::Kakasi::getopt_argv(\*(Aq\-w\*(Aq); .Ve .Sp Unlike \f(CWgetopt_argv()\fR which returns the status, \f(CW\*(C`set\*(C'\fR returns the object itself so you can go like this; .Sp .Vb 1 \& my $tokenized = $k\->set(\*(Aq\-w\*(Aq)\->get($raw_japanese); .Ve .Sp To get the status of \f(CW\*(C`$k\->set\*(C'\fR, use \f(CW\*(C`$k\->error\*(C'\fR. .Sp See also "Perl 5.8 Features". .ie n .IP $k\->error 2 .el .IP \f(CW$k\fR\->error 2 .IX Item "$k->error" returns the status of last method. .ie n .IP "$result = $k\->get($raw_japanese);" 2 .el .IP "\f(CW$result\fR = \f(CW$k\fR\->get($raw_japanese);" 2 .IX Item "$result = $k->get($raw_japanese);" OOP interface to \f(CW\*(C`do_kakasi\*(C'\fR. The following codes are equivalent. .Sp .Vb 4 \& # Functional \& getopt_argv(\*(Aq\-w\*(Aq); $result = do_kakasi($raw_japanese); \& # OOP \& $k\->set(\*(Aq\-w\*(Aq)\->get($raw_japanese); .Ve .SH "Perl 5.8 Features" .IX Header "Perl 5.8 Features" Perl 5.8 introduces Encode module which transcodes various encodings. This module takes advantage of this feature but to keep backward compatibility with version 1.x, This feature is enabled only when you use OOP interface (version 1.x only provided functional APIs). .PP On Perl 5.8 and up, \f(CW\*(C`\-i\fR\f(CIencoding\fR\f(CW\*(C'\fR and \f(CW\*(C`\-o\fR\f(CIencoding\fR\f(CW\*(C'\fRare handled by Encode module so you can use encodings Kakasi does not suppport such as utf8. In other words, .PP .Vb 1 \& $result = $k\->set(qw/\-iutf8 \-outf8 \-w/)\->get($utf8); .Ve .PP Is analogous to: .PP .Vb 4 \& $euc = encode(\*(Aqeucjp\*(Aq => $utf8); \& getopt_argv(\*(Aq\-w\*(Aq); \& $tmp = do_kakasi($euc); \& $result = decode(\*(Aqeucjp\*(Aq => $tmp); .Ve .PP When you specify \f(CW\*(C`\-outf8\*(C'\fR, \f(CW\*(C`$k\->get\*(C'\fR will return the string with utf8 flag on. .PP You can suppress this feature by setting \f(CW$Text::Kakasi::HAS_ENCODE\fR to 0 in which case this feature is not used. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBkakasi\fR\|(1), ,Encode,perlunicode .SH COPYRIGHT .IX Header "COPYRIGHT" .Vb 2 \& (C) 1998, 1999, 2000 NOKUBI Takatsugu \& (C) 2003 Dan Kogai .Ve .PP There is no warranty for this free software. Anyone can modify and/or redistribute this module under GNU GENERAL PUBLIC LICENSE. See COPYING file that is included in the archive for more details.