Skip to main content

Convert numbers from/to Japanese Numbers

Project description

jp_numbers.

Convert numbers from/to Japanese Numbers This is spin-off project from jp_prefecture

Install

pip install jp_numbers

How to use

from jp_numbers import JpNumberParser
jn = JpNumberParser()

class JpNunberPaser

  • kanji2number(val)
  • number2kanji(val, style)
    • style: 'kanji', 'arabic', 'mix', 'finance', 'daiji'
  • normalize_kanjinumber(val)
In [1]: from jp_prefecture.jp_numbers import JpNumberParser

In [2]: jn = JpNumberParser()

In [3]: jn.number2kanji(87654)
Out[3]: JpNumber(number=87654, as_str='87654', as_kanji='八万七千六百五十四')

In [4]: jn.number2kanji(87654, style='arabic')
Out[4]: JpNumber(number=87654, as_str='87654', as_kanji='87654')

In [5]: jn.number2kanji(87654, style='mix')
09:44:27.69 LOG:
09:44:27.78 .... count = 0
Out[5]: JpNumber(number=87654, as_str='87654', as_kanji='8万7654')

In [6]: jn.number2kanji(87654, style='finance')
Out[6]: JpNumber(number=87654, as_str='87654', as_kanji='87,654')

In [7]: jn.number2kanji(87654, style='daiji')
Out[7]: JpNumber(number=87654, as_str='87654', as_kanji='捌萬漆仟陸佰伍拾肆')

In [8]: jn.kanji2number('八万七千六百五十四')
Out[8]: JpNumber(number=87654, as_str='87654', as_kanji='八万七千六百五十四')

In [9]: jn.kanji2number('87654')
Out[9]: JpNumber(number=87654, as_str='87654', as_kanji='87654')

In [10]: jn.kanji2number('87,654')
Out[10]: JpNumber(number=87654, as_str='87654', as_kanji='87,654')

In [11]: jn.kanji2number('捌萬漆仟陸佰伍拾肆')
Out[11]: JpNumber(number=87654, as_str='87654', as_kanji='捌萬漆仟陸佰伍拾肆')

In [12]: jn.kanji2number('天神四丁目')
Out[12]: JpNumber(number=4, as_str='4', as_kanji='天神四丁目')

In [13]: jn.kanji2number('天神4丁目')
Out[13]: JpNumber(number=4, as_str='4', as_kanji='天神4丁目')

In [14]: jn.normalize_kanjinumber('京都府長岡京市天神2丁目15-13')
Out[14]: '京都府長岡京市天神二丁目十五-十三'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jp_number-0.0.1.tar.gz (7.3 kB view hashes)

Uploaded Source

Built Distribution

jp_number-0.0.1-py3-none-any.whl (7.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page