Archived
0
0

改进与新的文件格式

This commit is contained in:
2025-11-06 23:47:29 +08:00
parent a66b44bc98
commit 92f9903307
5 changed files with 30 additions and 16 deletions

View File

@@ -5,11 +5,11 @@ class ClozePuzzle(BasePuzzle):
"""填空题谜题生成器
Args:
text: 原始字符串(需要 "/" 分割句子, 末尾应有 "/")
text: 原始字符串(需要 delimiter 分割句子, 末尾应有 delimiter)
min_denominator: 最小概率倒数(如占所有可生成填空数的 1/7 中的 7, 若期望值小于 1, 则取 1)
"""
def __init__(self, text: str, min_denominator: int):
def __init__(self, text: str, delimiter: str = "/", min_denominator: int):
self.text = text
self.min_denominator = min_denominator
self.wording = "填空题 - 尚未刷新谜题"
@@ -17,7 +17,7 @@ class ClozePuzzle(BasePuzzle):
def refresh(self): # 刷新谜题
placeholder = "___SLASH___"
tmp_text = self.text.replace("/", placeholder)
tmp_text = self.text.replace(delimiter, placeholder)
words = tmp_text.split(placeholder)
if not words:
return