python 单词拆音节_新手求大神carry!关于单词音节问题!求救!

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

2526a58115cdf69ff327e06c2b36480e.png

def check_syllables(poem_lines, pattern, word_to_phonemes):

r""" (list of str, poetry pattern, pronunciation dictionary) -> list of str

Precondition: len(poem_lines) == len(pattern[0])

Return a list of lines from poem_lines that do not have the right number of

syllables for the poetry pattern according to the pronunciation dictionary.

If all lines have the right number of syllables, return the empty list.

>>> poem_lines = ['The first line leads off,', 'With a gap before the next.', 'Then the poem ends.']

>>> pattern = ([5, 5, 4], ['*', '*', '*'])

>>> word_to_phonemes = {'NEXT': ['N', 'EH1', 'K', 'S', 'T'],

... 'GAP': ['G', 'AE1', 'P'],

... 'BEFORE': ['B', 'IH0', 'F', 'AO1', 'R'],

... 'LEADS': ['L', 'IY1', 'D', 'Z'],

... 'WITH': ['W', 'IH1', 'DH'],

... 'LINE': ['L', 'AY1', 'N'],

... 'THEN': ['DH', 'EH1', 'N'],

... 'THE': ['DH', 'AH0'],

... 'A': ['AH0'],

... 'FIRST': ['F', 'ER1', 'S', 'T'],

... 'ENDS': ['EH1', 'N', 'D', 'Z'],

... 'POEM': ['P', 'OW1', 'AH0', 'M'],

... 'OFF': ['AO1', 'F']}

>>> check_syllables(poem_lines, pattern, word_to_phonemes)

['With a gap before the next.', 'Then the poem ends.']

>>> poem_lines = ['The first line leads off,']

>>> check_syllables(poem_lines, ([0], ['*']), word_to_phonemes)

[]

"""

万能的贴吧,有人可以告诉我这个到底怎么做啊!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值