PongsakornSET commited on
Commit
a268184
·
verified ·
1 Parent(s): 2c74110

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -3,14 +3,14 @@ import random
3
  import pandas as pd
4
 
5
  # Load the vocabulary data
6
- df = pd.read_csv("toeic_vocab_test_1")
7
  vocab_dict = dict()
8
  for line in df.iterrows():
9
  vocab_dict[line[1]['meaning']] = (line[1]['word'])
10
 
11
  # Function to generate a new question
12
  def generate_question():
13
- thai_word, (correct_answer, correct_part_of_speech) = random.choice(list(vocab_dict.items()))
14
 
15
  # Generate wrong answers
16
  wrong_answers = random.sample([v[0] for v in vocab_dict.values()], 4)
@@ -27,7 +27,7 @@ if 'question_data' not in st.session_state:
27
  st.session_state.question_data = generate_question()
28
  st.session_state.answered = False
29
 
30
- thai_word, correct_answer, correct_part_of_speech, options = st.session_state.question_data
31
 
32
  # Display question
33
  st.write(f"คำว่า '{thai_word}' (ชนิดคำ: {correct_part_of_speech}) คือคำว่าอะไร?")
 
3
  import pandas as pd
4
 
5
  # Load the vocabulary data
6
+ df = pd.read_csv("toeic_vocab_test_1.csv")
7
  vocab_dict = dict()
8
  for line in df.iterrows():
9
  vocab_dict[line[1]['meaning']] = (line[1]['word'])
10
 
11
  # Function to generate a new question
12
  def generate_question():
13
+ thai_word, correct_answer = random.choice(vocab_dict.items())
14
 
15
  # Generate wrong answers
16
  wrong_answers = random.sample([v[0] for v in vocab_dict.values()], 4)
 
27
  st.session_state.question_data = generate_question()
28
  st.session_state.answered = False
29
 
30
+ thai_word, correct_answer, options = st.session_state.question_data
31
 
32
  # Display question
33
  st.write(f"คำว่า '{thai_word}' (ชนิดคำ: {correct_part_of_speech}) คือคำว่าอะไร?")