相关疑难解决方法(0)

Ruby,Count音节

我正在使用ruby来计算我拥有的一些内容的Gunning Fog Index,我可以成功实现这里描述的算法:

Gunning雾指数

我使用以下方法来计算每个单词中的音节数:

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)

ruby nlp

8
推荐指数
1
解决办法
4992
查看次数

RegEx:比较两个字符串以查找Alliteration和Assonance

可以比较两个字符串来查找Alliteration和Assonance吗?

我主要使用javascript或php

javascript php regex

7
推荐指数
1
解决办法
1443
查看次数

标签 统计

javascript ×1

nlp ×1

php ×1

regex ×1

ruby ×1