1Kakasi(3)             User Contributed Perl Documentation            Kakasi(3)
2
3
4

NAME

6       Text::Kakasi - perl frontend to kakasi
7

SYNOPSIS

9         use Text::Kakasi;
10         # functional
11         $res = Text::Kakasi::getopt_argv('-JJ', '-c', '-w');
12         $str = Text::Kakasi::do_kakasi($japanese_text);
13         # object-oriented
14         $obj = Text::Kakasi->new('-JJ', '-c', '-w');
15         $str = $obj->get($japanese_text);
16

DESCRIPTION

18       This module provides interface to kakasi (kanji kana simple inverter).
19       kakasi is a set of programs and libraries which does what Japanese
20       input methods do in reverse order.  You feed Japanese and kakasi
21       converts it to phonetic representation thereof.  kakasi can also be
22       used to tokenizing Japanese text. To find more about kakasi, see
23       <http://kakasi.namazu.org/> .
24
25       Text::Kakasi now features both functional and object-oriented APIs.
26       functional APIs are 100% compatible with ver. 1.05.  But to take
27       advantage of "Perl 5.8 Features", you should use OOP APIs instead.
28
29       See Text::Kakasi::JP for the Japanese version of this document.
30

Functional APIs

32       Note "Text::Kakasi::" is omitted.  Text::Kakasi does not export these
33       functions by default.  You can import these function as follows;
34
35         use Text::Kakasi qw/getopt_argv do_kakasi/;
36
37       $err = getopt_argv($arg1, $arg2, ...)
38         initializes kakasi with options options are the same as "kakasi"
39         command.  Here is the summery as of kakasi 2.3.4.
40
41           -a[jE] -j[aE] -g[ajE] -k[ajKH]
42           -E[aj] -K[ajkH] -H[ajkK] -J[ajkKH]
43           -i{oldjis,newjis,dec,euc,sjis}
44            -o{oldjis,newjis,dec,euc,sjis}
45           -r{hepburn,kunrei} -p -s -f -c"chars"
46            [jisyo1, jisyo2,,,]
47
48           Character Sets:
49                a: ascii  j: jisroman  g: graphic  k: kana
50                (j,k     defined in jisx0201)
51                E: kigou  K: katakana  H: hiragana J: kanji
52                (E,K,H,J defined in jisx0208)
53
54           Options:
55             -i: input coding system    -o: output coding system
56             -r: romaji conversion system
57             -p: list all readings (with -J option)
58             -s: insert separate characters (with -J option)
59             -f: furigana mode (with -J option)
60             -c: skip chars within jukugo
61                 (with -J option: default TAB CR LF BLANK)
62             -C: romaji Capitalize (with -Ja or -Jj option)
63             -U: romaji Upcase     (with -Ja or -Jj option)
64             -u: call fflush() after 1 character output
65             -w: wakatigaki mode
66
67         Returns 0 on success and nonzero on failure.
68
69         Unlike version 1.x where you have to start the first argument with
70         "kakasi", you can omit that in version 2.x (adding "kakasi" does not
71         harm so compatibility is preserved).
72
73       $result_str = do_kakasi($str)
74         apply kakasi to $str and returns result. If anything goes wrong it
75         return "undef".
76
77       close_kanwadic()
78         closes dictionary files which are implicitly opened.  This function
79         is for backward compatibity only and you should never have to use
80         this function today.
81

Object-Oriented APIs

83       As of 2.0, Text::Kakasi also offers OOP APIs.
84
85       $k = Text::Kakasi->new($args ...)
86         Constructs object.  When argument is fed, it is the same as
87         "Text::Kakasi->new->set($args ...)"
88
89       $k->set($args ...)
90         OOP interface to "getopt_argv".
91
92           my $k = Text::Kakasi->new;
93           $k->set('-w'); # Text::Kakasi::getopt_argv('-w');
94
95         Unlike "getopt_argv()" which returns the status, "set" returns the
96         object itself so you can go like this;
97
98           my $tokenized = $k->set('-w')->get($raw_japanese);
99
100         To get the status of "$k->set", use "$k->error".
101
102         See also "Perl 5.8 Features".
103
104       $k->error
105         returns the status of last method.
106
107       $result = $k->get($raw_japanese);
108         OOP interface to "do_kakasi".  The following codes are equivalent.
109
110           # Functional
111           getopt_argv('-w'); $result = do_kakasi($raw_japanese);
112           # OOP
113           $k->set('-w')->get($raw_japanese);
114

Perl 5.8 Features

116       Perl 5.8 introduces Encode module which transcodes various encodings.
117       This module takes advantage of this feature but to keep backward
118       compatibility with version 1.x, This feature is enabled only when you
119       use OOP interface (version 1.x only provided functional APIs).
120
121       On Perl 5.8 and up, "-iencoding" and "-oencoding"are handled by Encode
122       module so you can use encodings Kakasi does not suppport such as utf8.
123       In other words,
124
125         $result = $k->set(qw/-iutf8 -outf8 -w/)->get($utf8);
126
127       Is analogous to:
128
129         $euc = encode('eucjp' => $utf8);
130         getopt_argv('-w');
131         $tmp = do_kakasi($euc);
132         $result = decode('eucjp' => $tmp);
133
134       When you specify "-outf8", "$k->get" will return the string with utf8
135       flag on.
136
137       You can suppress this feature by setting $Text::Kakasi::HAS_ENCODE to 0
138       in which case this feature is not used.
139

SEE ALSO

141       kakasi(1), <http://kakasi.namazu.org/>,Encode,perlunicode
142
144         (C) 1998, 1999, 2000 NOKUBI Takatsugu <knok@daionet.gr.jp>
145         (C) 2003 Dan Kogai <dankogai@dan.co.jp>
146
147       There is no warranty for this free software. Anyone can modify and/or
148       redistribute this module under GNU GENERAL PUBLIC LICENSE. See COPYING
149       file that is included in the archive for more details.
150
151
152
153perl v5.32.1                      2021-01-27                         Kakasi(3)
Impressum