问题描述
可能重复:
检测单词音节
有关踢(并刷上我的Python),我试图创建一种算法,将随机生成一个俳句(日本诗歌由三行,每5,7和5音节)。
For kicks (and to brush up on my Python), I'm trying to create an algorithm that will randomly generate a Haiku (Japanese poem made up of three lines with 5, 7, and 5 syllables each).
我碰到的问题(我使用的是EN-US.dic从Ubuntu的)被发现在一个字音节数。
The problem I've run into is finding the number of syllables in a word (I'm using the en-US.dic from Ubuntu).
目前,我有一个脚本运行,试图抓住报道本网站的数量,但是缓慢的,并且不产生许多命中。 这似乎更有前途,但我不知道如何使用Python来一句话注入自己的文本框中。
Currently, I have a script running that attempts to grab the number reported by this web site, but that is slow, and isn't generating many hits. This seems more promising, but I don't know how to use Python to inject a word into their text box.
我的问题是双重的:
- 有一个算法的方式来确定音节数的字(因此,并不需要进行上千次的Web请求的)?
- 我可以使用Python来注入的话到WordCalc?
推荐答案
下载白鲸连字符的单词列表一>。它拥有大多数英语单词和名称由音节断字。音节数将是连字符标记+空格数数+实际连字符+ 1。
Download the Moby Hyphenated Word List. It has most English words and names hyphenated by syllable. The number of syllables would be the number of hyphen markers + number of spaces + number of actual hyphens + 1.
这篇关于使用Python找音节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!