TuTuHuss
commited on
Commit
·
640922e
1
Parent(s):
794ea91
style(hus):add new chapter and new question
Browse files
llmriddles/questions/__init__.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
from .executor import QuestionExecutor
|
| 2 |
from .level1 import __file__ as _level1_file_
|
| 3 |
from .level3 import __file__ as _level3_file_
|
|
|
|
| 4 |
from .question import Question, register_question, list_ordered_questions
|
| 5 |
|
| 6 |
_ = _level1_file_
|
| 7 |
_ = _level3_file_
|
|
|
|
|
|
| 1 |
from .executor import QuestionExecutor
|
| 2 |
from .level1 import __file__ as _level1_file_
|
| 3 |
from .level3 import __file__ as _level3_file_
|
| 4 |
+
from .level4 import __file__ as _level4_file_
|
| 5 |
from .question import Question, register_question, list_ordered_questions
|
| 6 |
|
| 7 |
_ = _level1_file_
|
| 8 |
_ = _level3_file_
|
| 9 |
+
_ = _level4_file_
|
llmriddles/questions/level4.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .question import register_question
|
| 2 |
+
|
| 3 |
+
def count_words(text: str, contain_punctuation: bool = False):
|
| 4 |
+
chinese_words = []
|
| 5 |
+
english_words = []
|
| 6 |
+
other_words = []
|
| 7 |
+
temp_english_words = []
|
| 8 |
+
for char in text:
|
| 9 |
+
if '\u4e00' <= char <= '\u9fff':
|
| 10 |
+
chinese_words.append(char)
|
| 11 |
+
if len(temp_english_words) > 0:
|
| 12 |
+
english_words.append(''.join(temp_english_words))
|
| 13 |
+
temp_english_words = []
|
| 14 |
+
else:
|
| 15 |
+
if char.isalpha():
|
| 16 |
+
temp_english_words.append(char)
|
| 17 |
+
else:
|
| 18 |
+
if len(temp_english_words) > 0:
|
| 19 |
+
english_words.append(''.join(temp_english_words))
|
| 20 |
+
temp_english_words = []
|
| 21 |
+
other_words.append(char)
|
| 22 |
+
if contain_punctuation:
|
| 23 |
+
return len(chinese_words)+len(english_words)+len(other_words)
|
| 24 |
+
else:
|
| 25 |
+
return len(chinese_words)+len(english_words)
|
| 26 |
+
|
| 27 |
+
CN_TEXT_1 = """
|
| 28 |
+
第四章第一题(口是心非)请构造一个不少于十个字的问题,使得回答中不包含问题中的任意字符。
|
| 29 |
+
|
| 30 |
+
请在下面的输入框内填写你的提问并点击按钮提交。
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
EN_TEXT_1 = """
|
| 34 |
+
For the first question in chapter 3, Please construct a question of no less than ten words so that the answer does not contain any of the characters in the question.
|
| 35 |
+
|
| 36 |
+
Please enter your query below and click the submit button
|
| 37 |
+
"""
|
| 38 |
+
|
| 39 |
+
def _checker_1(question_text: str, user_text: str, answer_text: str, lang: str):
|
| 40 |
+
_ = question_text, lang
|
| 41 |
+
answer_text = answer_text.strip()
|
| 42 |
+
user_text = user_text.strip()
|
| 43 |
+
|
| 44 |
+
if count_words(user_text) < 10:
|
| 45 |
+
return False, "用户的问题长度应该至少10个字" if lang=='cn' else 'Question should be no less than 10 words.'
|
| 46 |
+
|
| 47 |
+
if answer_text == user_text:
|
| 48 |
+
return True, None
|
| 49 |
+
else:
|
| 50 |
+
return False, None
|
| 51 |
+
|
| 52 |
+
register_question({
|
| 53 |
+
'cn': CN_TEXT_1,
|
| 54 |
+
'en': EN_TEXT_1,
|
| 55 |
+
}, _checker_1, level=4)
|
| 56 |
+
|