Update app.py
Browse files
app.py
CHANGED
|
@@ -57,10 +57,10 @@ for split in korean_food_dataset.keys():
|
|
| 57 |
|
| 58 |
def find_related_restaurants(query: str, limit: int = 3) -> list:
|
| 59 |
"""
|
| 60 |
-
Query์ ๊ด๋ จ๋ ๋ฏธ์๋ฆฐ ๋ ์คํ ๋์
|
| 61 |
"""
|
| 62 |
try:
|
| 63 |
-
with open('
|
| 64 |
reader = csv.DictReader(f)
|
| 65 |
restaurants = list(reader)
|
| 66 |
|
|
@@ -75,6 +75,9 @@ def find_related_restaurants(query: str, limit: int = 3) -> list:
|
|
| 75 |
break
|
| 76 |
|
| 77 |
return related
|
|
|
|
|
|
|
|
|
|
| 78 |
except Exception as e:
|
| 79 |
print(f"Error finding restaurants: {e}")
|
| 80 |
return []
|
|
@@ -757,7 +760,7 @@ with gr.Blocks(
|
|
| 757 |
queue=False
|
| 758 |
)
|
| 759 |
|
| 760 |
-
|
| 761 |
with gr.TabItem("MICHELIN Restaurant", id="restaurant_tab"):
|
| 762 |
with gr.Row():
|
| 763 |
search_box = gr.Textbox(
|
|
@@ -767,13 +770,13 @@ with gr.Blocks(
|
|
| 767 |
)
|
| 768 |
cuisine_dropdown = gr.Dropdown(
|
| 769 |
label="์๋ฆฌ ์ข
๋ฅ",
|
| 770 |
-
choices=["์ ์ฒด"], #
|
| 771 |
value="์ ์ฒด",
|
| 772 |
scale=1
|
| 773 |
)
|
| 774 |
award_dropdown = gr.Dropdown(
|
| 775 |
label="๋ฏธ์๋ฆฐ ๋ฑ๊ธ",
|
| 776 |
-
choices=["์ ์ฒด"], #
|
| 777 |
value="์ ์ฒด",
|
| 778 |
scale=1
|
| 779 |
)
|
|
@@ -788,25 +791,27 @@ with gr.Blocks(
|
|
| 788 |
|
| 789 |
def init_dropdowns():
|
| 790 |
try:
|
| 791 |
-
with open('
|
| 792 |
reader = csv.DictReader(f)
|
| 793 |
restaurants = list(reader)
|
| 794 |
-
cuisines = ["์ ์ฒด"] +
|
| 795 |
-
|
|
|
|
|
|
|
| 796 |
return cuisines, awards
|
| 797 |
except FileNotFoundError:
|
| 798 |
-
print("Warning:
|
| 799 |
-
return ["์ ์ฒด"], ["์ ์ฒด"]
|
| 800 |
-
|
| 801 |
def search_restaurants(search_term, cuisine, award):
|
| 802 |
try:
|
| 803 |
-
with open('
|
| 804 |
reader = csv.DictReader(f)
|
| 805 |
restaurants = list(reader)
|
| 806 |
-
|
| 807 |
filtered = []
|
| 808 |
search_term = search_term.lower() if search_term else ""
|
| 809 |
-
|
| 810 |
for r in restaurants:
|
| 811 |
if search_term == "" or \
|
| 812 |
search_term in r['Name'].lower() or \
|
|
@@ -821,16 +826,16 @@ with gr.Blocks(
|
|
| 821 |
])
|
| 822 |
if len(filtered) >= 10: # ์ต๋ 10๊ฐ ๊ฒฐ๊ณผ๋ก ์ ํ
|
| 823 |
break
|
| 824 |
-
|
| 825 |
return filtered
|
| 826 |
except FileNotFoundError:
|
| 827 |
-
return [["ํ์ผ์ ์ฐพ์ ์ ์์ต๋๋ค", "", "", "", "", "", "
|
| 828 |
|
| 829 |
-
|
| 830 |
cuisines, awards = init_dropdowns()
|
| 831 |
cuisine_dropdown.choices = cuisines
|
| 832 |
award_dropdown.choices = awards
|
| 833 |
-
|
| 834 |
search_button.click(
|
| 835 |
search_restaurants,
|
| 836 |
inputs=[search_box, cuisine_dropdown, award_dropdown],
|
|
@@ -839,6 +844,7 @@ with gr.Blocks(
|
|
| 839 |
|
| 840 |
|
| 841 |
|
|
|
|
| 842 |
# ์ฌ์ฉ ๊ฐ์ด๋ ํญ
|
| 843 |
with gr.TabItem("์ด์ฉ ๋ฐฉ๋ฒ", id="instructions_tab"):
|
| 844 |
gr.Markdown(
|
|
|
|
| 57 |
|
| 58 |
def find_related_restaurants(query: str, limit: int = 3) -> list:
|
| 59 |
"""
|
| 60 |
+
Query์ ๊ด๋ จ๋ ๋ฏธ์๋ฆฐ ๋ ์คํ ๋์ michelin_my_maps.csv์์ ์ฐพ์ ๋ฐํ
|
| 61 |
"""
|
| 62 |
try:
|
| 63 |
+
with open('michelin_my_maps.csv', 'r', encoding='utf-8') as f:
|
| 64 |
reader = csv.DictReader(f)
|
| 65 |
restaurants = list(reader)
|
| 66 |
|
|
|
|
| 75 |
break
|
| 76 |
|
| 77 |
return related
|
| 78 |
+
except FileNotFoundError:
|
| 79 |
+
print("Warning: michelin_my_maps.csv file not found")
|
| 80 |
+
return []
|
| 81 |
except Exception as e:
|
| 82 |
print(f"Error finding restaurants: {e}")
|
| 83 |
return []
|
|
|
|
| 760 |
queue=False
|
| 761 |
)
|
| 762 |
|
| 763 |
+
# 4) ๋ฏธ์๋ฆฐ ๋ ์คํ ๋ ํญ
|
| 764 |
with gr.TabItem("MICHELIN Restaurant", id="restaurant_tab"):
|
| 765 |
with gr.Row():
|
| 766 |
search_box = gr.Textbox(
|
|
|
|
| 770 |
)
|
| 771 |
cuisine_dropdown = gr.Dropdown(
|
| 772 |
label="์๋ฆฌ ์ข
๋ฅ",
|
| 773 |
+
choices=[("์ ์ฒด", "์ ์ฒด")], # ์ด๊ธฐ๊ฐ ์ค์
|
| 774 |
value="์ ์ฒด",
|
| 775 |
scale=1
|
| 776 |
)
|
| 777 |
award_dropdown = gr.Dropdown(
|
| 778 |
label="๋ฏธ์๋ฆฐ ๋ฑ๊ธ",
|
| 779 |
+
choices=[("์ ์ฒด", "์ ์ฒด")], # ์ด๊ธฐ๊ฐ ์ค์
|
| 780 |
value="์ ์ฒด",
|
| 781 |
scale=1
|
| 782 |
)
|
|
|
|
| 791 |
|
| 792 |
def init_dropdowns():
|
| 793 |
try:
|
| 794 |
+
with open('michelin_my_maps.csv', 'r', encoding='utf-8') as f:
|
| 795 |
reader = csv.DictReader(f)
|
| 796 |
restaurants = list(reader)
|
| 797 |
+
cuisines = [("์ ์ฒด", "์ ์ฒด")] + [(cuisine, cuisine) for cuisine in
|
| 798 |
+
sorted(set(r['Cuisine'] for r in restaurants if r['Cuisine']))]
|
| 799 |
+
awards = [("์ ์ฒด", "์ ์ฒด")] + [(award, award) for award in
|
| 800 |
+
sorted(set(r['Award'] for r in restaurants if r['Award']))]
|
| 801 |
return cuisines, awards
|
| 802 |
except FileNotFoundError:
|
| 803 |
+
print("Warning: michelin_my_maps.csv file not found")
|
| 804 |
+
return [("์ ์ฒด", "์ ์ฒด")], [("์ ์ฒด", "์ ์ฒด")]
|
| 805 |
+
|
| 806 |
def search_restaurants(search_term, cuisine, award):
|
| 807 |
try:
|
| 808 |
+
with open('michelin_my_maps.csv', 'r', encoding='utf-8') as f:
|
| 809 |
reader = csv.DictReader(f)
|
| 810 |
restaurants = list(reader)
|
| 811 |
+
|
| 812 |
filtered = []
|
| 813 |
search_term = search_term.lower() if search_term else ""
|
| 814 |
+
|
| 815 |
for r in restaurants:
|
| 816 |
if search_term == "" or \
|
| 817 |
search_term in r['Name'].lower() or \
|
|
|
|
| 826 |
])
|
| 827 |
if len(filtered) >= 10: # ์ต๋ 10๊ฐ ๊ฒฐ๊ณผ๋ก ์ ํ
|
| 828 |
break
|
| 829 |
+
|
| 830 |
return filtered
|
| 831 |
except FileNotFoundError:
|
| 832 |
+
return [["ํ์ผ์ ์ฐพ์ ์ ์์ต๋๋ค", "", "", "", "", "", "michelin_my_maps.csv ํ์ผ์ ํ์ธํด์ฃผ์ธ์"]]
|
| 833 |
|
| 834 |
+
# ๋๋กญ๋ค์ด ์ด๊ธฐํ
|
| 835 |
cuisines, awards = init_dropdowns()
|
| 836 |
cuisine_dropdown.choices = cuisines
|
| 837 |
award_dropdown.choices = awards
|
| 838 |
+
|
| 839 |
search_button.click(
|
| 840 |
search_restaurants,
|
| 841 |
inputs=[search_box, cuisine_dropdown, award_dropdown],
|
|
|
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
+
|
| 848 |
# ์ฌ์ฉ ๊ฐ์ด๋ ํญ
|
| 849 |
with gr.TabItem("์ด์ฉ ๋ฐฉ๋ฒ", id="instructions_tab"):
|
| 850 |
gr.Markdown(
|