Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
import pandas as pd
|
3 |
|
4 |
# Load the DataFrame
|
5 |
-
url = "
|
6 |
df = pd.read_csv(url, encoding='utf-8-sig')
|
7 |
|
8 |
# Function to search years based on the selected mode
|
@@ -11,7 +11,7 @@ def search_years(search_mode, query):
|
|
11 |
matches = df[df['YEAR'].str.startswith(query[:4])]
|
12 |
elif search_mode == "Search Years by Keywords":
|
13 |
keyword_list = [keyword.strip() for keyword in query.split(',')]
|
14 |
-
matches = df[df['
|
15 |
else:
|
16 |
return [], "Please select exactly one search mode."
|
17 |
|
@@ -25,7 +25,7 @@ def get_image_html(year):
|
|
25 |
if not match.empty:
|
26 |
image_filename = match.iloc[0]['Filename']
|
27 |
image_url = f'https://huggingface.co/spaces/MK-316/TCE/raw/main/TExams/{image_filename}'
|
28 |
-
keywords = match.iloc[0]['
|
29 |
return f"<b>π· Keywords:</b> π {keywords}<br><img src='{image_url}' width='800'/>"
|
30 |
else:
|
31 |
return "No keywords found for this year.", "No image found for this year."
|
|
|
2 |
import pandas as pd
|
3 |
|
4 |
# Load the DataFrame
|
5 |
+
url = "TExam_new1014.csv"
|
6 |
df = pd.read_csv(url, encoding='utf-8-sig')
|
7 |
|
8 |
# Function to search years based on the selected mode
|
|
|
11 |
matches = df[df['YEAR'].str.startswith(query[:4])]
|
12 |
elif search_mode == "Search Years by Keywords":
|
13 |
keyword_list = [keyword.strip() for keyword in query.split(',')]
|
14 |
+
matches = df[df['TEXT'].apply(lambda x: any(keyword in x for keyword in keyword_list))]
|
15 |
else:
|
16 |
return [], "Please select exactly one search mode."
|
17 |
|
|
|
25 |
if not match.empty:
|
26 |
image_filename = match.iloc[0]['Filename']
|
27 |
image_url = f'https://huggingface.co/spaces/MK-316/TCE/raw/main/TExams/{image_filename}'
|
28 |
+
keywords = match.iloc[0]['TEXT']
|
29 |
return f"<b>π· Keywords:</b> π {keywords}<br><img src='{image_url}' width='800'/>"
|
30 |
else:
|
31 |
return "No keywords found for this year.", "No image found for this year."
|