python - 如何将法语单词转换为整数?

标签 python french

有关将英语单词转换为数字的其他问题已得到解答,特别是使用库 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/

相关文章:

python - 将 Pyqt GUI 主应用程序作为单独的非阻塞进程运行

python - 在 Pelican 中以 RST 格式编写的博客文章中添加 HTML

python - Pyglet,播放器,下一首歌

python - 如何更改Google语音识别的语言

Javascript正则表达式匹配法语字符

python - 模块子进程没有属性 'STARTF_USESHOWWINDOW'

python - 如何从列表中制作特征向量

javascript - 生成翻译 CSV 文件

python - 法语文本上的 NLTK word_tokenize 无法正常工作

c - 使用 scanf 阅读英语和法语双语