dataprincess commited on
Commit
f360851
·
verified ·
1 Parent(s): b9b741d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -134,11 +134,14 @@ def answer_lecturer_query(query):
134
 
135
  if max_score >= 1:
136
  if any(word in query for word in ["cosc", "geds", "ged"]):
137
- query_course_code = next((word for word in query.split() if word.startswith("cosc") or word.startswith("geds") or word.startswith("ged")), None)
138
- if query_course_code and query_course_code.upper() in best_match['course_code']:
139
- return process_query(query, best_match)
140
- else:
141
- return "Sorry, I couldn't find info about the course you've mentioned."
 
 
 
142
  else:
143
  return process_query(query, best_match)
144
  else:
 
134
 
135
  if max_score >= 1:
136
  if any(word in query for word in ["cosc", "geds", "ged"]):
137
+ for i, word in enumerate(query.split()):
138
+ if word.isdigit():
139
+ # Retrieve the prefix from the previous word
140
+ query_course_code = f"{query.split()[i - 1]} {word}"
141
+ if query_course_code.upper() == best_match['course_code']:
142
+ return process_query(query, best_match)
143
+ else:
144
+ return "Sorry, I couldn't find info about the course you've mentioned."
145
  else:
146
  return process_query(query, best_match)
147
  else: