Spaces:
Running
Running
Commit
·
2abb4ba
1
Parent(s):
681ec4e
Update app.py
Browse files
app.py
CHANGED
@@ -31,14 +31,17 @@ def random_spanish_pair():
|
|
31 |
random_pair = random.choice(json_data)
|
32 |
return jsonify(random_pair)
|
33 |
|
|
|
34 |
english_words = set()
|
35 |
spanish_words = set()
|
36 |
|
37 |
# Populate the word lists
|
38 |
for pair in json_data:
|
39 |
if "english" in pair:
|
|
|
40 |
english_words.update(re.findall(r'\b\w+\b', pair["english"]))
|
41 |
if "spanish" in pair:
|
|
|
42 |
spanish_words.update(re.findall(r'\b\w+\b', pair["spanish"]))
|
43 |
|
44 |
def get_distractors(target_word, all_words, num_distractors=3):
|
|
|
31 |
random_pair = random.choice(json_data)
|
32 |
return jsonify(random_pair)
|
33 |
|
34 |
+
# Lists to store English and Spanish words separately
|
35 |
english_words = set()
|
36 |
spanish_words = set()
|
37 |
|
38 |
# Populate the word lists
|
39 |
for pair in json_data:
|
40 |
if "english" in pair:
|
41 |
+
# Extract words from the English sentence
|
42 |
english_words.update(re.findall(r'\b\w+\b', pair["english"]))
|
43 |
if "spanish" in pair:
|
44 |
+
# Extract words from the Spanish sentence
|
45 |
spanish_words.update(re.findall(r'\b\w+\b', pair["spanish"]))
|
46 |
|
47 |
def get_distractors(target_word, all_words, num_distractors=3):
|