BillBojangeles2000 commited on
Commit
a5867f3
·
1 Parent(s): edc4138

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -91,11 +91,11 @@ class SubjectiveTest:
91
 
92
  def adjust_question_pattern(self, entity_label, topic_placeholder=True):
93
  question_patterns = {
94
- "PERSON": ["Who is {entity}?", "Tell me about {entity}", "Explain {entity}", "What do you know about {entity}"],
95
- "ORG": ["What is {entity}?", "Tell me about {entity}", "Explain {entity}", "What do you know about {entity}"],
96
- "GPE": ["Tell me about {entity}", "Explain {entity}", "What do you know about {entity}", "Describe {entity}", "Where is {entity}"],
97
- "MONEY": ["How much is {entity}?", "Tell me the value of {entity}", "Explain the amount of {entity}"],
98
- "DATE": ["Why was {entity} important?", "Explain what happened on {entity}"],
99
  # Add more entity-label to question-pattern mappings as needed
100
  }
101
 
@@ -103,7 +103,7 @@ class SubjectiveTest:
103
  for key in question_patterns:
104
  question_patterns[key] = [pattern + " {topic}" for pattern in question_patterns[key]]
105
 
106
- return question_patterns.get(entity_label, ["Explain {entity} {topic}"])
107
 
108
  def generate_test(self, topic=None):
109
  doc = self.nlp(self.summary)
@@ -115,11 +115,13 @@ class SubjectiveTest:
115
  entity_text = ent.text
116
  question_patterns = self.adjust_question_pattern(entity_label,"")
117
  for pattern in question_patterns:
118
- question = pattern.format(entity=entity_text, topic=topic)
119
- if entity_label in question_answer_dict:
120
- question_answer_dict[entity_label].append(question)
121
- else:
122
- question_answer_dict[entity_label] = [question]
 
 
123
 
124
  questions = []
125
 
@@ -129,6 +131,7 @@ class SubjectiveTest:
129
 
130
  return questions
131
 
 
132
  # Use st.form to encapsulate the quiz generation and submission
133
  with st.form("quiz_form"):
134
  # Create a button to initiate quiz generation
 
91
 
92
  def adjust_question_pattern(self, entity_label, topic_placeholder=True):
93
  question_patterns = {
94
+ "PERSON": ["Who is {entity}?", "Tell me about {entity}", "What do you know about {entity}"],
95
+ "ORG": ["What is {entity}?", "Tell me about {entity}", "What do you know about {entity}"],
96
+ "GPE": ["Tell me about {entity}", "What do you know about {entity}", "Where is {entity}"],
97
+ "MONEY": ["How much is {entity}?", "Tell me the value of {entity}"],
98
+ "DATE": ["Why was {entity} important?"],
99
  # Add more entity-label to question-pattern mappings as needed
100
  }
101
 
 
103
  for key in question_patterns:
104
  question_patterns[key] = [pattern + " {topic}" for pattern in question_patterns[key]]
105
 
106
+ return question_patterns.get(entity_label, ["{entity} {topic}"])
107
 
108
  def generate_test(self, topic=None):
109
  doc = self.nlp(self.summary)
 
115
  entity_text = ent.text
116
  question_patterns = self.adjust_question_pattern(entity_label,"")
117
  for pattern in question_patterns:
118
+ # Check if the pattern contains "Explain"
119
+ if "Explain" not in pattern:
120
+ question = pattern.format(entity=entity_text, topic=topic)
121
+ if entity_label in question_answer_dict:
122
+ question_answer_dict[entity_label].append(question)
123
+ else:
124
+ question_answer_dict[entity_label] = [question]
125
 
126
  questions = []
127
 
 
131
 
132
  return questions
133
 
134
+
135
  # Use st.form to encapsulate the quiz generation and submission
136
  with st.form("quiz_form"):
137
  # Create a button to initiate quiz generation