NAME

Lingua::JPN::Num2Word - Number to word conversion in Japanese

VERSION

version 0.2604300

SYNOPSIS

use Lingua::JPN::Num2Word qw(num2jpn_cardinal num2jpn_ordinal);

# Default output is kanji
say num2jpn_cardinal(3000);              # 三千
say num2jpn_cardinal(1234);              # 千二百三十四

# Hiragana
say num2jpn_cardinal(3000, 'hiragana');  # さんぜん

# Romaji (canonical, with rendaku)
say num2jpn_cardinal(3000, 'romaji');    # sanzen

# Ordinals
say num2jpn_ordinal(3);                  # 三番目
say num2jpn_ordinal(3, 'romaji');        # san-ban-me

DESCRIPTION

Converts numbers in the range [1, 1E16) to their textual Japanese representation in any of three scripts: kanji (default, e.g. 三千), hiragana (e.g. さんぜん), or romaji (e.g. sanzen).

Romaji output uses the canonical native pronunciation with rendaku (連濁) and gemination applied — that is, three thousand is rendered as sanzen, not san sen; six hundred as roppyaku, not roku hyaku.

Japanese decimal scaling proceeds in groups of four digits: 1 (一), 10 (十), 100 (百), 1000 (千), 10000 (万), 10^8 (億), 10^12 (兆).

FUNCTIONS

num2jpn_cardinal($number, [$script])

Convert $number to its Japanese cardinal text. $script is one of 'kanji' (default), 'hiragana', or 'romaji'.

num2jpn_cardinal(1234)              # 千二百三十四
num2jpn_cardinal(1234, 'hiragana')  # せんにひゃくさんじゅうよん
num2jpn_cardinal(1234, 'romaji')    # 'sen ni hyaku san ju yon'
num2jpn_ordinal($number, [$script])

Convert $number to its Japanese ordinal text by appending the ordinal suffix (番目 / ばんめ / -ban-me) to the cardinal form.

num2jpn_ordinal(3)                  # 三番目
num2jpn_ordinal(3, 'hiragana')      # さんばんめ
num2jpn_ordinal(3, 'romaji')        # san-ban-me
to_string($number)

DEPRECATED. Returns the romaji form as a list of words (no rendaku). Maintained for backward compatibility with Mike Schilli's original interface from 2001. New code should use num2jpn_cardinal($n, 'romaji').

capabilities (void)

Returns a hashref:

{ cardinal => 1, ordinal => 1, scripts => ['kanji', 'hiragana', 'romaji'] }

EXPORT_OK

num2jpn_cardinal
num2jpn_ordinal
to_string (deprecated)

AUTHORS

initial coding:
  Mike Schilli E<lt>m@perlmeister.comE<gt>
specification, maintenance:
  Richard C. Jelinek E<lt>rj@petamem.comE<gt>
maintenance, coding (2025-present):
  PetaMem AI Coding Agents

COPYRIGHT

Copyright (c) 2001 Mike Schilli. Copyright (c) PetaMem, s.r.o. 2002-present.

LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as the Artistic License 2.0 or the BSD 2-Clause License. See the LICENSE file in the distribution for details.