text2num
========
|docs|
``text2num`` is a python package that provides functions and parser classes for:
- Parsing of numbers expressed as words in French, English, Spanish, Portuguese, German and Catalan and convert them to integer values.
- Detection of ordinal, cardinal and decimal numbers in a stream of French, English, Spanish and Portuguese words and get their decimal digit representations. NOTE: Spanish does not support ordinal numbers yet.
- Detection of ordinal, cardinal and decimal numbers in a German text (BETA). NOTE: No support for 'relaxed=False' yet (behaves like 'True' by default).
Compatibility
-------------
Tested on python 3.7. Requires Python >= 3.6.
License
-------
This sofware is distributed under the MIT license of which you should have received a copy (see LICENSE file in this repository).
Installation
------------
``text2num`` does not depend on any other third party package.
To install text2num in your (virtual) environment::
pip install text2num
That's all folks!
Usage examples
--------------
Parse and convert
~~~~~~~~~~~~~~~~~
French examples:
.. code-block:: python
>>> from text_to_num import text2num
>>> text2num('quatre-vingt-quinze', "fr")
95
>>> text2num('nonante-cinq', "fr")
95
>>> text2num('mille neuf cent quatre-vingt dix-neuf', "fr")
1999
>>> text2num('dix-neuf cent quatre-vingt dix-neuf', "fr")
1999
>>> text2num("cinquante et un million cinq cent soixante dix-huit mille trois cent deux", "fr")
51578302
>>> text2num('mille mille deux cents', "fr")
ValueError: invalid literal for text2num: 'mille mille deux cent'
English examples:
.. code-block:: python
>>> from text_to_num import text2num
>>> text2num("fifty-one million five hundred seventy-eight thousand three hundred two", "en")
51578302
>>> text2num("eighty-one", "en")
81
Russian examples:
.. code-block:: python
>>> from text_to_num import text2num
>>> text2num("пятьдесят один миллион пятьсот семьдесят восемь тысяч триста два", "ru")
51578302
>>> text2num("миллиард миллион тысяча один", "ru")
1001001001
>>> text2num("один миллиард один миллион одна тысяча один", "ru")
1001001001
>>> text2num("восемьдесят один", "ru")
81
Spanish examples:
.. code-block:: python
>>> from text_to_num import text2num
>>> text2num("ochenta y uno", "es")
81
>>> text2num("nueve mil novecientos noventa y nueve", "es")
9999
>>> text2num("cincuenta y tres millones doscientos cuarenta y tres mil setecientos veinticuatro", "es")
53243724
Portuguese examples:
.. code-block:: python
>>> from text_to_num import text2num
>>> text2num("trinta e dois", "pt")
32
>>> text2num("mil novecentos e seis", "pt")
1906
>>> text2num("vinte e quatro milhões duzentos mil quarenta e sete", "pt")
24200047
German examples:
.. code-block:: python
>>> from text_to_num import text2num
>>> text2num("einundfünfzigmillionenfünfhundertachtundsiebzigtausenddreihundertzwei", "de")
51578302
>>> text2num("ein und achtzig", "de")
81
Catalan examples:
.. code-block:: python
>>> from text_to_num import text2num
>>> text2num('noranta-cinc', "ca")
95
>>> text2num('huitanta-u', "ca")
81
>>> text2num('mil nou-cents noranta-nou', "ca")
1999
>>> text2num("cinquanta-un milions cinc-cents setanta-vuit mil tres-cents dos", "ca")
51578302
>>> text2num('mil mil dos-cents', "ca")
ValueError: invalid literal for text2num: 'mil mil dos-cents'
Find and transcribe
~~~~~~~~~~~~~~~~~~~
Any numbers, even ordinals.
French:
.. code-block:: python
>>> from text_to_num import alpha2digit
>>> sentence = (
... "Huit cent quarante-deux pommes, vingt-cinq chiens, mille trois chevaux, "
... "douze mille six cent quatre-vingt-dix-huit clous.\n"
... "Quatre-vingt-quinze vaut nonante-cinq. On tolère l'absence de tirets avant les unités : "
... "soixante seize vaut septante six.\n"
... "Nombres en série : douze quinze zéro zéro quatre vingt cinquante-deux cent trois cinquante deux "
... "trente et un.\n"
... "Ordinaux: cinquième troisième vingt et unième centième mille deux cent trentième.\n"
... "Décimaux: douze virgule quatre-vingt dix-neuf, cent vingt virgule zéro cinq ; "
... "mais soixante zéro deux."
... )
>>> print(alpha2digit(sentence, "fr", ordinal_threshold=0))
842 pommes, 25 chiens, 1003 chevaux, 12698 clous.
95 vaut 95. On tolère l'absence de tirets avant les unités : 76 vaut 76.
Nombres en série : 12 15 004 20 52 103 52 31.
Ordinaux: 5ème 3ème 21ème 100ème 1230ème.
Décimaux: 12,99, 120,05 ; mais 60 02.
>>> sentence = "Cinquième premier second troisième vingt et unième centième mille deux cent trentième."
>>> print(alpha2digit(sentence, "fr", ordinal_threshold=3))
5ème premier second troisième 21ème 100ème 1230ème.
English:
.. code-block:: python
>>> from text_to_num import alpha2digit
>>> text = "On May twenty-third, I bought twenty-five cows, twelve chickens and one hundred twenty five point forty kg of potatoes."
>>> alpha2digit(text, "en")
'On May 23rd, I bought 25 cows, 12 chickens and 125.40 kg of potatoes.'
Russian:
.. code-block:: python
>>> from text_to_num import alpha2digit
>>> # дробная часть не обрабатывает уточнения вроде "пять десятых", "двенадцать сотых", "сколько-то стотысячных" и т.п., поэтому их лучше опускать
>>> text = "Двадцать пять коров, двенадцать сотен цыплят и сто двадцать пять точка сорок кг картофеля."
>>> alpha2digit(text, "ru")
'25 коров, 1200 цыплят и 125.40 кг картофеля.'
>>> text = "каждый пятый на первый второй расчитайсь!"
>>> alpha2digit(text, 'ru', ordinal_threshold=0)
'каждый 5ый на 1ый 2ой расчитайсь!'
Spanish (ordinals not supported yet):
.. code-block:: python
>>> from text_to_num import alpha2digit
>>> text = "Compramos veinticinco vacas, doce gallinas y ciento veinticinco coma cuarenta kg de patatas."
>>> alpha2digit(text, "es")
'Compramos 25 vacas, 12 gallinas y 125.40 kg de patatas.'
>>> text = "Tenemos mas veinte grados dentro y menos quince fuera."
>>> alpha2digit(text, "es")
'Tenemos +20 grados dentro y -15 fuera.'
Portuguese:
.. code-block:: python
>>> from text_to_num import alpha2digit
>>> text = "Comprámos vinte e cinco vacas, doze galinhas e cento vinte e cinco vírgula quarenta kg de batatas."
>>> alpha2digit(text, "pt")
'Comprámos 25 vacas, 12 galinhas e 125,40 kg de batatas.'
>>> text = "Temos mais vinte graus dentro e menos quinze fora."
>>> alpha2digit(text, "pt")
'Temos +20 graus dentro e -15 fora.'
>>> text = "Ordinais: quinto, terceiro, vigésimo, vigésimo primeiro, centésimo quarto"
>>> alpha2digit(text, "pt")
'Ordinais: 5º, terceiro, 20ª, 21º, 104º'
German (BETA, Note: 'relaxed' parameter is not supported yet and 'True' by default):
.. code-block:: python
>>> from text_to_num import alpha2digit
>>> text = "Ich habe fünfundzwanzig Kühe, zwölf Hühner und einhundertfünfundzwanzig kg Kartoffeln gekauft."
>>> alpha2digit(text, "de")
'Ich habe 25 Kühe, 12 Hühner und 125 kg Kartoffeln gekauft.'
>>> text = "Die Temperatur beträgt minus fünfzehn Grad."
>>> alpha2digit(text, "de")
'Die Temperatur beträgt -15 Grad.'
>>> text = "Die Telefonnummer lautet plus dreiunddreißig neun sechzig null sechs zwölf einundzwanzig."
>>> alpha2digit(text, "de")
'Die Telefonnummer lautet +33 9 60 0 6 12 21.'
>>> text = "Der zweiundzwanzigste Januar zweitausendzweiundzwanzig."
>>> alpha2digit(text, "de")
'22. Januar 2022'
>>> text = "Es ist ein Buch mit dreitausend Seiten aber nicht das erste."
>>> alpha2digit(text, "de", ordinal_threshold=0)
'Es ist ein Buch mit 3000 Seiten aber nicht das 1..'
>>> text = "Pi ist drei Komma eins vier und so weiter, aber nicht drei Komma vierzehn :-p"
>>> alpha2digit(text, "de", ordinal_threshold=0)
'Pi ist 3,14 und so weiter, aber nicht 3 Komma 14 :-p'
Catalan:
.. code-block:: python
>>> from text_to_num import alpha2digit
>>> text = ("Huit-centes quaranta-dos pomes, vint-i-cinc gossos, mil tres cavalls, dotze mil sis-cents noranta-huit claus.\n Vuitanta-u és igual a huitanta-u.\n Nombres en sèrie: dotze quinze zero zero quatre vint cinquanta-dos cent tres cinquanta-dos trenta-u.\n Ordinals: cinquè tercera vint-i-uena centè mil dos-cents trentena.\n Decimals: dotze coma noranta-nou, cent vint coma zero cinc; però seixanta zero dos.")
>>> print(alpha2digit(text, "ca", ordinal_threshold=0))
842 pomes, 25 gossos, 1003 cavalls, 12698 claus.
81 és igual a 81.
Nombres en sèrie: 12 15 004 20 52 103 52 31.
Ordinals: 5è 3a 21a 100è 1230a.
Decimals: 12,99, 120,05; però 60 02.
>>> text = "Cinqué primera segona tercer vint-i-ué centena mil dos-cents trenté."
>>> print(alpha2digit(text, "ca", ordinal_threshold=3))
5é primera segona tercer 21é 100a 1230é.
>>> text = "Compràrem vint-i-cinc vaques, dotze gallines i cent vint-i-cinc coma quaranta kg de creïlles."
>>> alpha2digit(text, "ca")
'Compràrem 25 vaques, 12 gallines i 125,40 kg de creïlles.'
>>> text = "Fa més vint graus dins i menys quinze fora."
>>> alpha2digit(text, "ca")
'Fa +20 graus dins i -15 fora.'
Read the complete documentation on `ReadTheDocs <http://text2num.readthedocs.io/>`_.
Contribute
----------
Join us on https://github.com/allo-media/text2num
.. |docs| image:: https://readthedocs.org/projects/text2num/badge/?version=latest
:target: https://text2num.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
Raw data
{
"_id": null,
"home_page": "https://github.com/allo-media/text2num",
"name": "text2num",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "French Spanish English Portuguese German Catalan Russion NLP words-to-numbers",
"author": "Allo-Media",
"author_email": "contact@allo-media.fr",
"download_url": "https://files.pythonhosted.org/packages/cf/07/63c363d8222b0be56a99f0b3b491a701f07e27cf355b8dfcf1514b9c0fd6/text2num-2.5.1.tar.gz",
"platform": null,
"description": "text2num\n========\n\n|docs|\n\n\n``text2num`` is a python package that provides functions and parser classes for:\n\n- Parsing of numbers expressed as words in French, English, Spanish, Portuguese, German and Catalan and convert them to integer values.\n- Detection of ordinal, cardinal and decimal numbers in a stream of French, English, Spanish and Portuguese words and get their decimal digit representations. NOTE: Spanish does not support ordinal numbers yet.\n- Detection of ordinal, cardinal and decimal numbers in a German text (BETA). NOTE: No support for 'relaxed=False' yet (behaves like 'True' by default).\n\nCompatibility\n-------------\n\nTested on python 3.7. Requires Python >= 3.6.\n\nLicense\n-------\n\nThis sofware is distributed under the MIT\u00a0license of which you should have received a copy (see LICENSE file in this repository).\n\nInstallation\n------------\n\n``text2num`` does not depend on any other third party package.\n\nTo install text2num in your (virtual) environment::\n\n pip install text2num\n\nThat's all folks!\n\nUsage examples\n--------------\n\nParse and convert\n~~~~~~~~~~~~~~~~~\n\n\nFrench examples:\n\n.. code-block:: python\n\n >>> from text_to_num import text2num\n >>> text2num('quatre-vingt-quinze', \"fr\")\n 95\n\n >>> text2num('nonante-cinq', \"fr\")\n 95\n\n >>> text2num('mille neuf cent quatre-vingt dix-neuf', \"fr\")\n 1999\n\n >>> text2num('dix-neuf cent quatre-vingt dix-neuf', \"fr\")\n 1999\n\n >>> text2num(\"cinquante et un million cinq cent soixante dix-huit mille trois cent deux\", \"fr\")\n 51578302\n\n >>> text2num('mille mille deux cents', \"fr\")\n ValueError: invalid literal for text2num: 'mille mille deux cent'\n\n\nEnglish examples:\n\n.. code-block:: python\n\n >>> from text_to_num import text2num\n\n >>> text2num(\"fifty-one million five hundred seventy-eight thousand three hundred two\", \"en\")\n 51578302\n\n >>> text2num(\"eighty-one\", \"en\")\n 81\n\n\nRussian examples:\n\n.. code-block:: python\n\n >>> from text_to_num import text2num\n\n >>> text2num(\"\u043f\u044f\u0442\u044c\u0434\u0435\u0441\u044f\u0442 \u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u043f\u044f\u0442\u044c\u0441\u043e\u0442 \u0441\u0435\u043c\u044c\u0434\u0435\u0441\u044f\u0442 \u0432\u043e\u0441\u0435\u043c\u044c \u0442\u044b\u0441\u044f\u0447 \u0442\u0440\u0438\u0441\u0442\u0430 \u0434\u0432\u0430\", \"ru\")\n 51578302\n\n >>> text2num(\"\u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434 \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0442\u044b\u0441\u044f\u0447\u0430 \u043e\u0434\u0438\u043d\", \"ru\")\n 1001001001\n\n >>> text2num(\"\u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434 \u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u043e\u0434\u043d\u0430 \u0442\u044b\u0441\u044f\u0447\u0430 \u043e\u0434\u0438\u043d\", \"ru\")\n 1001001001\n\n >>> text2num(\"\u0432\u043e\u0441\u0435\u043c\u044c\u0434\u0435\u0441\u044f\u0442 \u043e\u0434\u0438\u043d\", \"ru\")\n 81\n\n\nSpanish examples:\n\n.. code-block:: python\n\n >>> from text_to_num import text2num\n >>> text2num(\"ochenta y uno\", \"es\")\n 81\n\n >>> text2num(\"nueve mil novecientos noventa y nueve\", \"es\")\n 9999\n\n >>> text2num(\"cincuenta y tres millones doscientos cuarenta y tres mil setecientos veinticuatro\", \"es\")\n 53243724\n\n\nPortuguese examples:\n\n.. code-block:: python\n\n >>> from text_to_num import text2num\n >>> text2num(\"trinta e dois\", \"pt\")\n 32\n\n >>> text2num(\"mil novecentos e seis\", \"pt\")\n 1906\n\n >>> text2num(\"vinte e quatro milh\u00f5es duzentos mil quarenta e sete\", \"pt\")\n 24200047\n\n\nGerman examples:\n\n.. code-block:: python\n\n >>> from text_to_num import text2num\n\n >>> text2num(\"einundf\u00fcnfzigmillionenf\u00fcnfhundertachtundsiebzigtausenddreihundertzwei\", \"de\")\n 51578302\n\n >>> text2num(\"ein und achtzig\", \"de\")\n 81\n\n\nCatalan examples:\n\n.. code-block:: python\n\n >>> from text_to_num import text2num\n >>> text2num('noranta-cinc', \"ca\")\n 95\n\n >>> text2num('huitanta-u', \"ca\")\n 81\n\n >>> text2num('mil nou-cents noranta-nou', \"ca\")\n 1999\n\n >>> text2num(\"cinquanta-un milions cinc-cents setanta-vuit mil tres-cents dos\", \"ca\")\n 51578302\n\n >>> text2num('mil mil dos-cents', \"ca\")\n ValueError: invalid literal for text2num: 'mil mil dos-cents'\n\n\nFind and transcribe\n~~~~~~~~~~~~~~~~~~~\n\nAny numbers, even ordinals.\n\nFrench:\n\n.. code-block:: python\n\n >>> from text_to_num import alpha2digit\n >>> sentence = (\n ... \"Huit cent quarante-deux pommes, vingt-cinq chiens, mille trois chevaux, \"\n ... \"douze mille six cent quatre-vingt-dix-huit clous.\\n\"\n ... \"Quatre-vingt-quinze vaut nonante-cinq. On tol\u00e8re l'absence de tirets avant les unit\u00e9s : \"\n ... \"soixante seize vaut septante six.\\n\"\n ... \"Nombres en s\u00e9rie : douze quinze z\u00e9ro z\u00e9ro quatre vingt cinquante-deux cent trois cinquante deux \"\n ... \"trente et un.\\n\"\n ... \"Ordinaux: cinqui\u00e8me troisi\u00e8me vingt et uni\u00e8me centi\u00e8me mille deux cent trenti\u00e8me.\\n\"\n ... \"D\u00e9cimaux: douze virgule quatre-vingt dix-neuf, cent vingt virgule z\u00e9ro cinq ; \"\n ... \"mais soixante z\u00e9ro deux.\"\n ... )\n >>> print(alpha2digit(sentence, \"fr\", ordinal_threshold=0))\n 842 pommes, 25 chiens, 1003 chevaux, 12698 clous.\n 95 vaut 95. On tol\u00e8re l'absence de tirets avant les unit\u00e9s : 76 vaut 76.\n Nombres en s\u00e9rie : 12 15 004 20 52 103 52 31.\n Ordinaux: 5\u00e8me 3\u00e8me 21\u00e8me 100\u00e8me 1230\u00e8me.\n D\u00e9cimaux: 12,99, 120,05 ; mais 60 02.\n\n >>> sentence = \"Cinqui\u00e8me premier second troisi\u00e8me vingt et uni\u00e8me centi\u00e8me mille deux cent trenti\u00e8me.\"\n >>> print(alpha2digit(sentence, \"fr\", ordinal_threshold=3))\n 5\u00e8me premier second troisi\u00e8me 21\u00e8me 100\u00e8me 1230\u00e8me.\n\n\nEnglish:\n\n.. code-block:: python\n\n >>> from text_to_num import alpha2digit\n\n >>> text = \"On May twenty-third, I bought twenty-five cows, twelve chickens and one hundred twenty five point forty kg of potatoes.\"\n >>> alpha2digit(text, \"en\")\n 'On May 23rd, I bought 25 cows, 12 chickens and 125.40 kg of potatoes.'\n\n\nRussian:\n\n.. code-block:: python\n\n >>> from text_to_num import alpha2digit\n\n >>> # \u0434\u0440\u043e\u0431\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u044f \u0432\u0440\u043e\u0434\u0435 \"\u043f\u044f\u0442\u044c \u0434\u0435\u0441\u044f\u0442\u044b\u0445\", \"\u0434\u0432\u0435\u043d\u0430\u0434\u0446\u0430\u0442\u044c \u0441\u043e\u0442\u044b\u0445\", \"\u0441\u043a\u043e\u043b\u044c\u043a\u043e-\u0442\u043e \u0441\u0442\u043e\u0442\u044b\u0441\u044f\u0447\u043d\u044b\u0445\" \u0438 \u0442.\u043f., \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u043b\u0443\u0447\u0448\u0435 \u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c\n >>> text = \"\u0414\u0432\u0430\u0434\u0446\u0430\u0442\u044c \u043f\u044f\u0442\u044c \u043a\u043e\u0440\u043e\u0432, \u0434\u0432\u0435\u043d\u0430\u0434\u0446\u0430\u0442\u044c \u0441\u043e\u0442\u0435\u043d \u0446\u044b\u043f\u043b\u044f\u0442 \u0438 \u0441\u0442\u043e \u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044c \u043f\u044f\u0442\u044c \u0442\u043e\u0447\u043a\u0430 \u0441\u043e\u0440\u043e\u043a \u043a\u0433 \u043a\u0430\u0440\u0442\u043e\u0444\u0435\u043b\u044f.\"\n >>> alpha2digit(text, \"ru\")\n '25 \u043a\u043e\u0440\u043e\u0432, 1200 \u0446\u044b\u043f\u043b\u044f\u0442 \u0438 125.40 \u043a\u0433 \u043a\u0430\u0440\u0442\u043e\u0444\u0435\u043b\u044f.'\n\n >>> text = \"\u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u044f\u0442\u044b\u0439 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0441\u0447\u0438\u0442\u0430\u0439\u0441\u044c!\"\n >>> alpha2digit(text, 'ru', ordinal_threshold=0)\n '\u043a\u0430\u0436\u0434\u044b\u0439 5\u044b\u0439 \u043d\u0430 1\u044b\u0439 2\u043e\u0439 \u0440\u0430\u0441\u0447\u0438\u0442\u0430\u0439\u0441\u044c!'\n\n\nSpanish (ordinals not supported yet):\n\n.. code-block:: python\n\n >>> from text_to_num import alpha2digit\n\n >>> text = \"Compramos veinticinco vacas, doce gallinas y ciento veinticinco coma cuarenta kg de patatas.\"\n >>> alpha2digit(text, \"es\")\n 'Compramos 25 vacas, 12 gallinas y 125.40 kg de patatas.'\n\n >>> text = \"Tenemos mas veinte grados dentro y menos quince fuera.\"\n >>> alpha2digit(text, \"es\")\n 'Tenemos +20 grados dentro y -15 fuera.'\n\n\nPortuguese:\n\n.. code-block:: python\n\n >>> from text_to_num import alpha2digit\n\n >>> text = \"Compr\u00e1mos vinte e cinco vacas, doze galinhas e cento vinte e cinco v\u00edrgula quarenta kg de batatas.\"\n >>> alpha2digit(text, \"pt\")\n 'Compr\u00e1mos 25 vacas, 12 galinhas e 125,40 kg de batatas.'\n\n >>> text = \"Temos mais vinte graus dentro e menos quinze fora.\"\n >>> alpha2digit(text, \"pt\")\n 'Temos +20 graus dentro e -15 fora.'\n\n >>> text = \"Ordinais: quinto, terceiro, vig\u00e9simo, vig\u00e9simo primeiro, cent\u00e9simo quarto\"\n >>> alpha2digit(text, \"pt\")\n 'Ordinais: 5\u00ba, terceiro, 20\u00aa, 21\u00ba, 104\u00ba'\n\n\nGerman (BETA, Note: 'relaxed' parameter is not supported yet and 'True' by default):\n\n.. code-block:: python\n\n >>> from text_to_num import alpha2digit\n\n >>> text = \"Ich habe f\u00fcnfundzwanzig K\u00fche, zw\u00f6lf H\u00fchner und einhundertf\u00fcnfundzwanzig kg Kartoffeln gekauft.\"\n >>> alpha2digit(text, \"de\")\n 'Ich habe 25 K\u00fche, 12 H\u00fchner und 125 kg Kartoffeln gekauft.'\n\n >>> text = \"Die Temperatur betr\u00e4gt minus f\u00fcnfzehn Grad.\"\n >>> alpha2digit(text, \"de\")\n 'Die Temperatur betr\u00e4gt -15 Grad.'\n\n >>> text = \"Die Telefonnummer lautet plus dreiunddrei\u00dfig neun sechzig null sechs zw\u00f6lf einundzwanzig.\"\n >>> alpha2digit(text, \"de\")\n 'Die Telefonnummer lautet +33 9 60 0 6 12 21.'\n\n >>> text = \"Der zweiundzwanzigste Januar zweitausendzweiundzwanzig.\"\n >>> alpha2digit(text, \"de\")\n '22. Januar 2022'\n\n >>> text = \"Es ist ein Buch mit dreitausend Seiten aber nicht das erste.\"\n >>> alpha2digit(text, \"de\", ordinal_threshold=0)\n 'Es ist ein Buch mit 3000 Seiten aber nicht das 1..'\n\n >>> text = \"Pi ist drei Komma eins vier und so weiter, aber nicht drei Komma vierzehn :-p\"\n >>> alpha2digit(text, \"de\", ordinal_threshold=0)\n 'Pi ist 3,14 und so weiter, aber nicht 3 Komma 14 :-p'\n\n\nCatalan:\n\n.. code-block:: python\n\n >>> from text_to_num import alpha2digit\n >>> text = (\"Huit-centes quaranta-dos pomes, vint-i-cinc gossos, mil tres cavalls, dotze mil sis-cents noranta-huit claus.\\n Vuitanta-u \u00e9s igual a huitanta-u.\\n Nombres en s\u00e8rie: dotze quinze zero zero quatre vint cinquanta-dos cent tres cinquanta-dos trenta-u.\\n Ordinals: cinqu\u00e8 tercera vint-i-uena cent\u00e8 mil dos-cents trentena.\\n Decimals: dotze coma noranta-nou, cent vint coma zero cinc; per\u00f2 seixanta zero dos.\")\n >>> print(alpha2digit(text, \"ca\", ordinal_threshold=0))\n 842 pomes, 25 gossos, 1003 cavalls, 12698 claus.\n 81 \u00e9s igual a 81.\n Nombres en s\u00e8rie: 12 15 004 20 52 103 52 31.\n Ordinals: 5\u00e8 3a 21a 100\u00e8 1230a.\n Decimals: 12,99, 120,05; per\u00f2 60 02.\n\n >>> text = \"Cinqu\u00e9 primera segona tercer vint-i-u\u00e9 centena mil dos-cents trent\u00e9.\"\n >>> print(alpha2digit(text, \"ca\", ordinal_threshold=3))\n 5\u00e9 primera segona tercer 21\u00e9 100a 1230\u00e9.\n\n >>> text = \"Compr\u00e0rem vint-i-cinc vaques, dotze gallines i cent vint-i-cinc coma quaranta kg de cre\u00eflles.\"\n >>> alpha2digit(text, \"ca\")\n 'Compr\u00e0rem 25 vaques, 12 gallines i 125,40 kg de cre\u00eflles.'\n\n >>> text = \"Fa m\u00e9s vint graus dins i menys quinze fora.\"\n >>> alpha2digit(text, \"ca\")\n 'Fa +20 graus dins i -15 fora.'\n\n\nRead the complete documentation on `ReadTheDocs <http://text2num.readthedocs.io/>`_.\n\nContribute\n----------\n\nJoin us on https://github.com/allo-media/text2num\n\n\n.. |docs| image:: https://readthedocs.org/projects/text2num/badge/?version=latest\n :target: https://text2num.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Parse and convert numbers written in French, Spanish, English, Portuguese, German, Catalan or Russion into their digit representation.",
"version": "2.5.1",
"project_urls": {
"Homepage": "https://github.com/allo-media/text2num"
},
"split_keywords": [
"french",
"spanish",
"english",
"portuguese",
"german",
"catalan",
"russion",
"nlp",
"words-to-numbers"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9dd5ac86a19f575afc230db0be12f959e7f5976dd698d4d427ad85bafd0641d7",
"md5": "3601fb12524b298b29d7750c97aaded6",
"sha256": "6d55daee015399db2833d55966f3ff6d7c773fa652f99b0d6b06e619e1363462"
},
"downloads": -1,
"filename": "text2num-2.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3601fb12524b298b29d7750c97aaded6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 59225,
"upload_time": "2024-03-19T16:18:01",
"upload_time_iso_8601": "2024-03-19T16:18:01.094179Z",
"url": "https://files.pythonhosted.org/packages/9d/d5/ac86a19f575afc230db0be12f959e7f5976dd698d4d427ad85bafd0641d7/text2num-2.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cf0763c363d8222b0be56a99f0b3b491a701f07e27cf355b8dfcf1514b9c0fd6",
"md5": "cc7537232ce3191fabe469b31b24fe9a",
"sha256": "c060201fa24b7b97f3190045e95e6f2b283ae7ac172cbe482a3a4ef06eb208c4"
},
"downloads": -1,
"filename": "text2num-2.5.1.tar.gz",
"has_sig": false,
"md5_digest": "cc7537232ce3191fabe469b31b24fe9a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 37480,
"upload_time": "2024-03-19T16:18:04",
"upload_time_iso_8601": "2024-03-19T16:18:04.383502Z",
"url": "https://files.pythonhosted.org/packages/cf/07/63c363d8222b0be56a99f0b3b491a701f07e27cf355b8dfcf1514b9c0fd6/text2num-2.5.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-19 16:18:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "allo-media",
"github_project": "text2num",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"circle": true,
"lcname": "text2num"
}