我正在使用ruby来计算我拥有的一些内容的Gunning Fog Index,我可以成功实现这里描述的算法:
我使用以下方法来计算每个单词中的音节数:
Tokenizer = /([aeiouy]{1,3})/
def count_syllables(word)
len = 0
if word[-3..-1] == 'ing' then
len += 1
word = word[0...-3]
end
got = word.scan(Tokenizer)
len += got.size()
if got.size() > 1 and got[-1] == ['e'] and
word[-1].chr() == 'e' and
word[-2].chr() != 'l' then
len -= 1
end
return len
end
Run Code Online (Sandbox Code Playgroud)
它有时只用2个音节来拾取有3个音节的单词.任何人都可以提出任何建议或者知道更好的方法吗?
text = "The word logorrhoea is often used pejoratively to describe prose that is highly abstract and contains little concrete language. Since abstract writing …Run Code Online (Sandbox Code Playgroud) 可以比较两个字符串来查找Alliteration和Assonance吗?
我主要使用javascript或php