Spaces:
Running
on
Zero
Running
on
Zero
Update breed_comparison.py
Browse files- breed_comparison.py +8 -8
breed_comparison.py
CHANGED
@@ -9,21 +9,19 @@ def create_comparison_tab(dog_breeds, get_dog_description, breed_noise_info, bre
|
|
9 |
breed_display_mapping = { breed: breed.replace('_', ' ').title() for breed in dog_breeds}
|
10 |
reversed_mapping = {v: k for k ,v in breed_display_mapping.items()}
|
11 |
|
12 |
-
|
13 |
-
return x.lower()
|
14 |
-
sorted_display_names = sorted(breed_display_mapping.values(), key=sort_key)
|
15 |
|
16 |
with gr.TabItem("Breed Comparison"):
|
17 |
gr.HTML("<p style='text-align: center;'>Select two dog breeds to compare their characteristics and care requirements.</p>")
|
18 |
|
19 |
with gr.Row():
|
20 |
breed1_dropdown = gr.Dropdown(
|
21 |
-
choices=
|
22 |
label="Select First Breed",
|
23 |
value="Golden_Retriever"
|
24 |
)
|
25 |
breed2_dropdown = gr.Dropdown(
|
26 |
-
choices=
|
27 |
label="Select Second Breed",
|
28 |
value="Border_Collie"
|
29 |
)
|
@@ -360,10 +358,12 @@ def create_comparison_tab(dog_breeds, get_dog_description, breed_noise_info, bre
|
|
360 |
}
|
361 |
"""
|
362 |
|
363 |
-
def show_comparison(
|
364 |
if not breed1 or not breed2:
|
365 |
return "Please select two breeds to compare"
|
366 |
|
|
|
|
|
367 |
breed1_info = get_dog_description(breed1)
|
368 |
breed2_info = get_dog_description(breed2)
|
369 |
breed1_noise = breed_noise_info.get(breed1, {})
|
@@ -454,7 +454,7 @@ def create_comparison_tab(dog_breeds, get_dog_description, breed_noise_info, bre
|
|
454 |
|
455 |
return f"""
|
456 |
<div class="breed-column">
|
457 |
-
<h2 class="section-title">π {breed
|
458 |
|
459 |
<div class="info-section">
|
460 |
{create_info_item('Size', info['Size'], section_tooltips['Size'])}
|
@@ -510,7 +510,7 @@ def create_comparison_tab(dog_breeds, get_dog_description, breed_noise_info, bre
|
|
510 |
<a href="https://www.akc.org/dog-breeds/{breed.lower().replace('_', '-')}/"
|
511 |
class="learn-more-btn"
|
512 |
target="_blank">
|
513 |
-
π Learn more about {breed
|
514 |
</a>
|
515 |
</div>
|
516 |
"""
|
|
|
9 |
breed_display_mapping = { breed: breed.replace('_', ' ').title() for breed in dog_breeds}
|
10 |
reversed_mapping = {v: k for k ,v in breed_display_mapping.items()}
|
11 |
|
12 |
+
sorted_display_names = sorted(breed_display_mapping.values(), key=lambda x: x.lower())
|
|
|
|
|
13 |
|
14 |
with gr.TabItem("Breed Comparison"):
|
15 |
gr.HTML("<p style='text-align: center;'>Select two dog breeds to compare their characteristics and care requirements.</p>")
|
16 |
|
17 |
with gr.Row():
|
18 |
breed1_dropdown = gr.Dropdown(
|
19 |
+
choices=sorted_display_names,
|
20 |
label="Select First Breed",
|
21 |
value="Golden_Retriever"
|
22 |
)
|
23 |
breed2_dropdown = gr.Dropdown(
|
24 |
+
choices=sorted_display_names,
|
25 |
label="Select Second Breed",
|
26 |
value="Border_Collie"
|
27 |
)
|
|
|
358 |
}
|
359 |
"""
|
360 |
|
361 |
+
def show_comparison(breed1_display, breed2_display):
|
362 |
if not breed1 or not breed2:
|
363 |
return "Please select two breeds to compare"
|
364 |
|
365 |
+
breed1 = reverse_mapping[breed1_display]
|
366 |
+
breed2 = reverse_mapping[breed2_display]
|
367 |
breed1_info = get_dog_description(breed1)
|
368 |
breed2_info = get_dog_description(breed2)
|
369 |
breed1_noise = breed_noise_info.get(breed1, {})
|
|
|
454 |
|
455 |
return f"""
|
456 |
<div class="breed-column">
|
457 |
+
<h2 class="section-title">π {breed_display_mapping[breed]}</h2>
|
458 |
|
459 |
<div class="info-section">
|
460 |
{create_info_item('Size', info['Size'], section_tooltips['Size'])}
|
|
|
510 |
<a href="https://www.akc.org/dog-breeds/{breed.lower().replace('_', '-')}/"
|
511 |
class="learn-more-btn"
|
512 |
target="_blank">
|
513 |
+
π Learn more about {breed_display_mapping[breed]} on AKC
|
514 |
</a>
|
515 |
</div>
|
516 |
"""
|