NAME
Lingua::JPN::Word2Num - Word to number conversion in Japanese
VERSION
version 0.2604300
SYNOPSIS
use Lingua::JPN::Word2Num qw(w2n);
# Kanji
say w2n('三千'); # 3000
say w2n('千二百三十四'); # 1234
# Hiragana
say w2n('さんぜん'); # 3000
say w2n('せんにひゃくさんじゅうよん'); # 1234
# Romaji — natural forms with rendaku
say w2n('sanzen'); # 3000
say w2n('roppyaku'); # 600
say w2n('hassen'); # 8000
# Romaji — legacy un-rendaku'd forms (also accepted)
say w2n('san sen'); # 3000
say w2n('roku hyaku'); # 600
DESCRIPTION
Converts Japanese numeral text to integer values. Accepts input in kanji, hiragana, or romaji — script is auto-detected.
For romaji, both the canonical native pronunciation (with rendaku and gemination, e.g. sanzen, roppyaku, hassen) and the older un-rendaku'd transliteration (san sen, roku hyaku, hachi sen) are accepted. Output canonical text comes from Lingua::JPN::Num2Word; this module is intentionally permissive on input.
Recognised range: 0 to 9,999,999,999,999,999 (just under 10^16).
FUNCTIONS
- w2n($text)
-
Convert text representation to a number. Returns
undefif the input is not recognised as a Japanese numeral. - ordinal2cardinal($text)
-
Convert ordinal text to cardinal text by stripping the ordinal suffix (番目 / ばんめ / -ban-me). Returns
undefif the input is not an ordinal. - jpn_numerals (void)
-
Internal — returns a fresh Parse::RecDescent parser object.
EXPORT_OK
- w2n
- ordinal2cardinal
AUTHORS
specification, maintenance:
Richard C. Jelinek E<lt>rj@petamem.comE<gt>
maintenance, coding (2025-present):
PetaMem AI Coding Agents
COPYRIGHT
Copyright (c) PetaMem, s.r.o. 2004-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.