Bases: HtmlKeyboardResponse
Category-learning stimulus based on a binary feature vector.
Feature order
0 shape (0 circle, 1 triangle)
1 color (0 orange #E69F00, 1 blue #0072B2)
2 size (0 small, 1 large)
3 border (0 none, 1 pink #CC79A7)
4 pattern (0 filled, 1 striped)
5 inner_mark (0 none, 1 star)
Source code in sweetbean/stimulus/DefaultCategoryLearning.py
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221 | class DefaultCategoryLearning(HtmlKeyboardResponse):
"""
Category-learning stimulus based on a binary feature vector.
Feature order:
0 shape (0 circle, 1 triangle)
1 color (0 orange #E69F00, 1 blue #0072B2)
2 size (0 small, 1 large)
3 border (0 none, 1 pink #CC79A7)
4 pattern (0 filled, 1 striped)
5 inner_mark (0 none, 1 star)
"""
l_template = "You see a {{ feature_description }}."
def __init__(
self,
duration=None,
feature_vector=None,
choices=None,
correct_key="",
prompt_template=None,
response_template=None,
side_effects=None,
):
if feature_vector is None:
raise ValueError("feature_vector is required for DefaultCategoryLearning.")
# TimelineVariable / other Variables are resolved at runtime; validate then.
if isinstance(feature_vector, list):
_validate_feature_vector(feature_vector)
elif not isinstance(feature_vector, Variable):
raise ValueError(
"feature_vector must be a list of 0/1 values or a SweetBean Variable "
"(e.g. TimelineVariable('feature_vector'))."
)
stimulus = FunctionVariable(
"default_category_learning_stimulus",
_feature_vector_to_html,
[feature_vector],
)
feature_description = FunctionVariable(
"default_category_learning_description",
_feature_vector_to_description,
[feature_vector],
)
super().__init__(
duration=duration,
stimulus=stimulus,
choices=choices,
correct_key=correct_key,
side_effects=side_effects,
)
if prompt_template is not None:
self.l_template = prompt_template
if response_template is not None:
self.response_template = response_template
self.arg.update(
{
"feature_vector": feature_vector,
"feature_description": feature_description,
}
)
|