mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-19 17:49:24 +01:00
* 1. add a challenge in chapter 2 as challenge 9 2. add a check_challenge.py script to makesure a challenge actually has answer 3. add blank lines to the file README_CN.md to look better * delete redundant function * code style check * code style check * style checkout change --------- Co-authored-by: DuskSwan <aquark@foxmail.com>
36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
def check_word_in_sentence(words, sentence):
|
|
return [word in sentence for word in words]
|
|
|
|
|
|
challenge5 = {
|
|
'name':
|
|
'第五章 登堂入室',
|
|
'problems': [
|
|
{
|
|
'title':
|
|
'第1题 盛夏少年',
|
|
'description':
|
|
'模型的回答应该包含“盛夏”、“蝉鸣”、“少年”、“橘子味汽水”这几个词,同时输入的问题不能包含其中任一个词。',
|
|
'validator':
|
|
lambda response, input: all(
|
|
check_word_in_sentence(['盛夏', '蝉鸣', '少年', '橘子味汽水'], response))
|
|
and not any(
|
|
check_word_in_sentence(['盛夏', '蝉鸣', '少年', '橘子味汽水'], input))
|
|
},
|
|
{
|
|
'title':
|
|
'第2题 蝉鸣日出',
|
|
'description':
|
|
'模型的回答应该包含“盛夏”、“蝉鸣”、“少年”、“橘子味汽水”、“日出”这几个词,同时输入的问题不能包含其中任一个字。',
|
|
'validator':
|
|
lambda response, input: all(
|
|
check_word_in_sentence(
|
|
['盛夏', '蝉鸣', '少年', '橘子味汽水', '日出'], response)) and not any(
|
|
check_word_in_sentence([
|
|
'盛', '夏', '蝉', '鸣', '少', '年', '橘', '子', '味', '汽',
|
|
'水', '日', '出'
|
|
], input))
|
|
},
|
|
]
|
|
}
|