rhyme.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:RapBattleAlexa 作者: akashlevy 项目源码 文件源码
def get_syllables(sonnet):

  from nltk.tokenize import wordpunct_tokenize
  tokens = [wordpunct_tokenize(s) for s in sonnet]
  punct = set(['.', ',', '!', ':', ';'])
  filtered = [ [w for w in sentence if w not in punct ] for sentence in tokens]
  last = [ sentence[len(sentence) - 1] for sentence in filtered]

  syllables = [[(word, len(pron), pron) for (word, pron) in cmu_dict if word == w] for w in last]
  return syllables
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号