有关将英语单词转换为数字的其他问题已得到解答,特别是使用库 w2n或其他自定义算法。
但是我不知道如何将法语(或一般来说,任何语言的)单词转换为整数,例如:
>>> word_to_number('quarante-quatre')
44
我的法语不是很流利,但它肯定不只是试图翻译 https://github.com/akshaynagpal/w2n/blob/master/word2number/w2n.py 中的文字。对吧?
最佳答案
只是用谷歌搜索了一下,发现了一个名称非常相似的项目,名为 text2num那:
provides functions and parser classes for:
- parsing numbers expressed as words in French and convert them to integer values;
他们的演示:
from text_to_num import text2num
text2num('quatre-vingt-quinze')
返回 95
,这似乎是正确的
关于python - 如何将法语单词转换为整数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58219158/