-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
326 lines (309 loc) · 6.23 KB
/
Copy pathtest.py
File metadata and controls
326 lines (309 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
import random
wordSet = ([
{
"akkr": [
"us (2 people, accusative)",
"us (2 people, dative)"
]
},
{
"akkar": "us (2 people, genitive)"
},
{
"aldri": "never"
},
{
"aptr": "again"
},
{
"at": "that"
},
{
"barn n.": "kid"
},
{
"bestr": "horse"
},
{
"bíð": "group of men (army)"
},
{
"borg f.": "elevated place"
},
{
"braut": "away"
},
{
"bús n.": "house"
},
{
"dvergr m.": "dwarf"
},
{
"eigi": "don't"
},
{
"eiðr m.": "oath"
},
{
"ek": "I (nominative)"
},
{
"eldr m.": "fire"
},
{
"en": "but"
},
{
"er": "[\"where\",\"which\",\"is\"]"
},
{
"eða": "or"
},
{
"fjall n.": "mountain"
},
{
"flǫgð f.": "witch"
},
{
"friðr m.": "peace"
},
{
"fótr m.": "foot"
},
{
"fǫr f.": "journey"
},
{
"garðr m.": "fence"
},
{
"goð n.": "god"
},
{
"gras n.": "grass"
},
{
"haf n.": "ocean"
},
{
"hann": "he"
},
{
"heimr m.": "home"
},
{
"heðan": "(from) here"
},
{
"hingat": "(come) here"
},
{
"hringr m.": "ring"
},
{
"hugr m.": "mind"
},
{
"hvat": "what"
},
{
"hversu": "how"
},
{
"hér": "(at) here"
},
{
"illa": "bad"
},
{
"jǫrð f.": "earth"
},
{
"kostr m.": "choice"
},
{
"lag n.": "order"
},
{
"land n.": "land"
},
{
"maðr m.": "person"
},
{
"mik": "me (accusative)"
},
{
"mjǫk": "very"
},
{
"mál n.": "[\"speech\",\"business\"]"
},
{
"mér": "me (dative)"
},
{
"mín": "my (genitive)"
},
{
"nú": "now"
},
{
"ok": "and"
},
{
"oss": [
"us (accusative)",
"us (dative)"
]
},
{
"skip n.": "ship"
},
{
"skǫmm f.": "shame"
},
{
"sonr m.": "son"
},
{
"strǫnd f.": "beach"
},
{
"stuðr m.": "place"
},
{
"svá": "so"
},
{
"vald n.": "control"
},
{
"var": "was"
},
{
"vatn n.": "water"
},
{
"vel": "well"
},
{
"verǫld f.": "world"
},
{
"vindr m.": "wind"
},
{
"vinr m.": "friend"
},
{
"vit": "we (nominative)"
},
{
"vǫllr m.": "valley"
},
{
"vár": "our (genitive)"
},
{
"vér": "we (nominative)"
},
{
"áðr": "before"
},
{
"ætt f.": "[\"family\",\"direction\"]"
},
{
"álfr m.": "elf"
},
{
"þangat": "(to) there"
},
{
"þar": "(at) there"
},
{
"þat": "it"
},
{
"þaðan": "(from) there"
},
{
"þá": "then"
},
{
"þó": "though"
},
{
"Þorskr m.": "cod"
},
{
"ǫld f.": "age"
}
])
def get_word_and_def(word_dict):
"""Helper to extract the word and definition from the dictionary item."""
word = list(word_dict.keys())[0]
definition = word_dict[word]
if isinstance(definition, list):
# Join multiple definitions for display
definition = ", ".join(definition)
elif isinstance(definition, str) and definition.startswith('["') and definition.endswith('"]'):
# Clean up the string representation of a list
definition = definition.strip('[]').replace('"', '').replace('\\','')
return word, definition
def newQuestionSet(wordSet, amount):
# Ensure 'amount' doesn't exceed the number of words available
if amount > len(wordSet):
amount = len(wordSet)
# Randomly select unique words for the questions
questions_words = random.sample(wordSet, amount)
sets = []
# Create a list of all potential decoy words (the whole wordSet)
decoy_pool = list(wordSet)
for word_dict in questions_words:
# The word being questioned
correct_word, correct_def = get_word_and_def(word_dict)
# Select 3 unique decoy definitions
# Filter the decoy pool to exclude the current word_dict
filtered_decoy_pool = [item for item in decoy_pool if item != word_dict]
# Select 3 other random words from the filtered pool
# Handle case where there might be fewer than 3 decoys
num_decoys = 3
if len(filtered_decoy_pool) < num_decoys:
num_decoys = len(filtered_decoy_pool)
decoys = random.sample(filtered_decoy_pool, num_decoys)
# Build the options list with the correct definition and the decoys' definitions
options = []
# Extract and format the definitions for the decoys
decoy_definitions = [get_word_and_def(d)[1] for d in decoys]
# Combine the correct definition with the decoy definitions
all_options_defs = [correct_def] + decoy_definitions
# Shuffle the options and find the new index of the correct answer
random.shuffle(all_options_defs)
corPos = all_options_defs.index(correct_def)
set = {
'question': correct_word, # The word the user has to define
'options': all_options_defs,
'corIndex': corPos, # The 0-indexed position of the correct answer
'dir': radom.random
}
sets.append(set)
return sets
def askQuestion(question):
print(question.question)
questions = len(question.options)
for i in range(0,questions):
print(f'{i+1}: {question.options[i]}')
else:
print(f'enter an Number beetwen 0 and {questions} ')
userInput = input()
if int(userInput) == question.corIndex:
print('yay <_>')
else:
print('wrong ):')
questionSet = newQuestionSet(wordSet,4)
print(questionSet)