Spaces:
Running
on
Zero
Running
on
Zero
Upload 5 files
Browse files- animal_detector.db +0 -0
- data_manager.py +777 -0
- history_manager.py +88 -0
- search_history.py +154 -0
- styles.py +785 -0
animal_detector.db
ADDED
Binary file (81.9 kB). View file
|
|
data_manager.py
ADDED
@@ -0,0 +1,777 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import sqlite3
|
3 |
+
from dataclasses import dataclass
|
4 |
+
from typing import List, Dict, Optional
|
5 |
+
from decimal import Decimal
|
6 |
+
from breed_health_info import breed_health_info, default_health_note
|
7 |
+
import numpy as np
|
8 |
+
import random
|
9 |
+
|
10 |
+
|
11 |
+
def create_table():
|
12 |
+
conn = sqlite3.connect('animal_detector.db')
|
13 |
+
cursor = conn.cursor()
|
14 |
+
|
15 |
+
cursor.execute('''
|
16 |
+
CREATE TABLE IF NOT EXISTS AnimalCatalog (
|
17 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
18 |
+
Species TEXT NOT NULL,
|
19 |
+
Breed TEXT NOT NULL,
|
20 |
+
Size_Category TEXT,
|
21 |
+
Typical_Lifespan TEXT,
|
22 |
+
Temperament TEXT,
|
23 |
+
Care_Level TEXT,
|
24 |
+
Good_With_Children BOOLEAN,
|
25 |
+
Exercise_Needs TEXT,
|
26 |
+
Grooming_Needs TEXT,
|
27 |
+
Brief_Description TEXT
|
28 |
+
)
|
29 |
+
''')
|
30 |
+
|
31 |
+
conn.commit()
|
32 |
+
cursor.close()
|
33 |
+
conn.close()
|
34 |
+
|
35 |
+
# 創建表
|
36 |
+
create_table()
|
37 |
+
|
38 |
+
def insert_dog_data():
|
39 |
+
conn = sqlite3.connect('animal_detector.db')
|
40 |
+
cursor = conn.cursor()
|
41 |
+
|
42 |
+
dog_data = [
|
43 |
+
('Dog', 'Afghan_Hound', 'Large', '12-18 years', 'Independent, dignified, aloof', 'High', True, 'High', 'High', 'Known for their long, silky coat and regal appearance, Afghan Hounds are ancient sighthounds with a unique, elegant presence.'),
|
44 |
+
('Dog', 'African_Hunting_Dog', 'Medium', '10-12 years', 'Social, intelligent, energetic', 'Very High', False, 'Very High', 'Low', 'Also called African Wild Dogs, these are not domestic dogs and are endangered in their native habitats.'),
|
45 |
+
('Dog', 'Airedale', 'Large', '10-12 years', 'Friendly, clever, courageous', 'High', True, 'High', 'High', 'Known as the "King of Terriers," Airedales are the largest of the terrier breeds and very versatile. Originally from Aire Valley of Yorkshire, they served in police and military roles while maintaining their hunting abilities.'),
|
46 |
+
('Dog', 'American_Staffordshire_Terrier', 'Medium', '12-16 years', 'Confident, good-natured, courageous', 'Moderate', True, 'High', 'Low', 'Often confused with Pit Bulls, Am Staffs are strong, muscular dogs with a gentle and loving nature.'),
|
47 |
+
('Dog', 'Appenzeller', 'Medium', '12-15 years', 'Reliable, fearless, lively', 'High', True, 'High', 'Moderate', 'Swiss mountain dogs known for their agility and enthusiasm, Appenzellers make excellent working and family dogs. Traditional cattle herders from the Swiss Alps, they combine working intelligence with devoted guardianship.'),
|
48 |
+
('Dog', 'Australian_Terrier', 'Small', '12-15 years', 'Courageous, spirited, alert', 'Moderate', True, 'Moderate', 'Moderate', 'Small, sturdy terriers originally bred to control rodents, known for their confident personality. First breed developed in Australia, combining the tenacity of old terrier breeds with adaptability to harsh conditions.'),
|
49 |
+
('Dog', 'Bedlington_Terrier', 'Medium', '11-16 years', 'Mild, gentle, lively', 'High', True, 'Moderate', 'High', 'Known for their lamb-like appearance, Bedlington Terriers are energetic and good with families. Despite their gentle look, they were originally miners\' dogs bred for hunting vermin and remain surprisingly fast and athletic.'),
|
50 |
+
('Dog', 'Bernese_Mountain_Dog', 'Large', '6-8 years', 'Good-natured, calm, strong', 'High', True, 'Moderate', 'High', 'Large, tri-colored Swiss working dogs known for their gentle nature and striking appearance. Despite their short lifespan, they are excellent family companions and draft dogs. Often called "Berners", they are patient with children but prone to heat sensitivity due to their thick coat.'),
|
51 |
+
('Dog', 'Blenheim_Spaniel', 'Small', '12-14 years', 'Affectionate, gentle, lively', 'Moderate', True, 'Moderate', 'High', 'A color variety of the Cavalier King Charles Spaniel, known for their red and white coat and friendly nature.'),
|
52 |
+
('Dog', 'Border_Collie', 'Medium', '12-15 years', 'Intelligent, energetic, alert', 'High', True, 'Very High', 'Moderate', 'Often considered the most intelligent dog breed, Border Collies are tireless workers with intense herding instincts. Known for their "eye" - a distinctive herding gaze, they excel in dog sports and need constant mental stimulation to prevent boredom.'),
|
53 |
+
('Dog', 'Border_Terrier', 'Small', '12-15 years', 'Affectionate, intelligent, even-tempered', 'Moderate', True, 'High', 'Low', 'Small but tough terriers with an otter-like head, known for their friendly and adaptable nature.'),
|
54 |
+
('Dog', 'Boston_Bull', 'Small', '11-13 years', 'Friendly, lively, intelligent', 'Moderate', True, 'Moderate', 'Low', 'Also known as Boston Terriers, these "American Gentlemen" are friendly and adaptable. First bred in Boston as fighting dogs, they evolved into beloved companions known for their tuxedo-like coat pattern and gentle disposition.'),
|
55 |
+
('Dog', 'Bouvier_Des_Flandres', 'Large', '10-12 years', 'Gentle, loyal, rational', 'High', True, 'High', 'High', 'Large, powerful herding dogs with a tousled coat, known for their versatility and even temperament. Originally bred as cattle drivers in Flanders, they excel in various roles from farm work to family protection.'),
|
56 |
+
('Dog', 'Brabancon_Griffon', 'Small', '12-15 years', 'Self-important, sensitive, affectionate', 'Moderate', False, 'Moderate', 'Low', 'Also known as the Brussels Griffon, these small dogs have a distinctive beard and mustache, giving them an almost human-like expression.'),
|
57 |
+
('Dog', 'Brittany_Spaniel', 'Medium', '12-14 years', 'Bright, fun-loving, upbeat', 'High', True, 'High', 'Moderate', 'Versatile hunting dogs and active companions, Brittanys are known for their energy and intelligence. Originally from France, these agile bird dogs excel in both hunting and family life with their eager and athletic nature.'),
|
58 |
+
('Dog', 'Cardigan', 'Small', '12-15 years', 'Affectionate, loyal, intelligent', 'Moderate', True, 'Moderate', 'Moderate', 'Distinguished from Pembroke Welsh Corgis by their long tail, Cardigans are intelligent herding dogs with a fox-like appearance.'),
|
59 |
+
('Dog', 'Chesapeake_Bay_Retriever', 'Large', '10-13 years', 'Bright, sensitive, affectionate', 'High', True, 'High', 'Moderate', 'Known for their waterproof coat, Chessies are strong swimmers and excellent retrievers. Developed in the American Chesapeake Bay region, they are famous for their ability to work in icy waters and their distinctive wavy coat.'),
|
60 |
+
('Dog', 'Chihuahua', 'Small', '12-20 years', 'Charming, graceful, sassy', 'Moderate', False, 'Low', 'Low', 'One of the smallest dog breeds, known for their big personalities and loyalty to their owners. Named after Mexico\'s largest state, they are ancient companions with terrier-like attitudes and remarkably long lifespans for dogs.'),
|
61 |
+
('Dog', 'Dandie_Dinmont', 'Small', '12-15 years', 'Independent, intelligent, dignified', 'Moderate', True, 'Moderate', 'Moderate', 'Recognizable by their long body and distinctive topknot of hair on their head. Named after a character in Sir Walter Scott novel, these unique terriers combine determination with dignity, making them distinctive companions.'),
|
62 |
+
('Dog', 'Doberman', 'Large', '10-12 years', 'Loyal, fearless, alert', 'High', True, 'High', 'Low', 'Sleek, athletic dogs known for their intelligence and loyalty, often used as guard dogs. Highly trainable and protective, they excel in both working roles and as family guardians.'),
|
63 |
+
('Dog', 'English_Foxhound', 'Medium', '10-13 years', 'Friendly, active, gentle', 'High', True, 'Very High', 'Low', 'Athletic, pack-oriented hounds originally bred for fox hunting in England. Known for their stamina, melodious voice, and strong hunting instincts.'),
|
64 |
+
('Dog', 'English_Setter', 'Large', '10-12 years', 'Gentle, friendly, placid', 'High', True, 'High', 'High', 'Known for their speckled coat or "belton" markings, English Setters are elegant bird dogs and affectionate companions.'),
|
65 |
+
('Dog', 'English_Springer', 'Medium', '12-14 years', 'Friendly, playful, obedient', 'High', True, 'High', 'High', 'Energetic and eager to please, Springers are excellent hunting dogs and loving family pets. Their name comes from their hunting style of "springing" at game birds, combining strong work ethics with a merry, affectionate family nature.'),
|
66 |
+
('Dog', 'EntleBucher', 'Medium', '11-13 years', 'Loyal, enthusiastic, intelligent', 'High', True, 'High', 'Low', 'The smallest of the Swiss Mountain Dogs, known for their agility and herding abilities. Originally from the Swiss valley of Entlebuch, they combine the strength of mountain dogs with remarkable agility and quick thinking.'),
|
67 |
+
('Dog', 'Eskimo_Dog', 'Large', '10-15 years', 'Alert, loyal, intelligent', 'High', True, 'High', 'High', 'Also known as the Canadian Eskimo Dog, these are strong, resilient working dogs adapted to Arctic conditions. Ancient breed used by Inuit people for hunting and transportation, known for their power and endurance.'),
|
68 |
+
('Dog', 'French_Bulldog', 'Small', '10-12 years', 'Playful, adaptable, smart', 'Moderate', True, 'Low', 'Low', 'French Bulldogs are small, muscular dogs with a smooth coat, short face, and bat-like ears. They are affectionate, playful, and well-suited for family living.'),
|
69 |
+
('Dog', 'German_Shepherd', 'Large', '10-13 years', 'Confident, courageous, smart', 'High', True, 'High', 'Moderate', 'Versatile working dogs, German Shepherds excel in various roles from police work to family protection.'),
|
70 |
+
('Dog', 'German_Short-Haired_Pointer', 'Large', '10-12 years', 'Friendly, intelligent, willing to please', 'High', True, 'Very High', 'Moderate', 'Versatile hunting dogs known for their pointer stance, these dogs excel in both water and land retrieving.'),
|
71 |
+
('Dog', 'Gordon_Setter', 'Large', '10-12 years', 'Confident, fearless, alert', 'High', True, 'High', 'High', 'The largest of the setter breeds, Gordon Setters are known for their black and tan coloring and loyal nature. Developed in Scotland, these noble bird dogs combine strong hunting abilities with devoted family loyalty.'),
|
72 |
+
('Dog', 'Great_Dane', 'Giant', '7-10 years', 'Friendly, patient, dependable', 'High', True, 'Moderate', 'Low', 'One of the largest dog breeds, Great Danes are known as gentle giants with a friendly disposition. Originally bred for hunting large game, these noble giants now excel as loving family companions despite their imposing size.'),
|
73 |
+
('Dog', 'Great_Pyrenees', 'Large', '10-12 years', 'Patient, calm, gentle', 'High', True, 'Moderate', 'High', 'Large, powerful dogs originally bred to guard livestock, known for their gentle and protective nature. These ancient guardians of the Pyrenees mountains combine strength and nobility with a deep devotion to family and flock.'),
|
74 |
+
('Dog', 'Greater_Swiss_Mountain_dog', 'Large', '8-11 years', 'Faithful, alert, vigilant', 'Moderate', True, 'Moderate', 'Low', 'Large, strong working dogs with a tricolor coat, Swissies are gentle giants with a calm temperament.'),
|
75 |
+
('Dog', 'Ibizan_Hound', 'Medium', '12-14 years', 'Even-tempered, loyal, independent', 'Moderate', True, 'High', 'Low', 'Sleek, athletic sighthounds known for their large, erect ears and red and white coats. Ancient breed from Balearic Islands, they can jump remarkable heights and were bred to hunt rabbits in difficult terrain.'),
|
76 |
+
('Dog', 'Irish_Setter', 'Large', '11-15 years', 'Outgoing, sweet-tempered, active', 'High', True, 'High', 'High', 'Recognizable by their rich red coat, Irish Setters are energetic and playful dogs that love family life.'),
|
77 |
+
('Dog', 'Irish_Terrier', 'Medium', '12-16 years', 'Bold, daring, intelligent', 'Moderate', True, 'High', 'Moderate', 'Known as the Daredevil of dogdom, Irish Terriers are courageous and loyal with a distinctive red coat. One of the oldest terrier breeds, they earned fame for their bravery as messenger dogs in World War I.'),
|
78 |
+
('Dog', 'Irish_Water_Spaniel', 'Large', '10-12 years', 'Playful, brave, intelligent', 'High', True, 'High', 'High', 'Largest of the spaniels, known for their curly, liver-colored coat and rat-like tail. These distinctive water retrievers combine the agility of a spaniel with the endurance of a retriever, featuring a water-repellent double coat.'),
|
79 |
+
('Dog', 'Irish_Wolfhound', 'Giant', '6-8 years', 'Gentle, patient, dignified', 'High', True, 'Moderate', 'Moderate', 'The tallest of all dog breeds, Irish Wolfhounds are gentle giants known for their calm and friendly nature. Ancient warriors of Ireland, they once hunted wolves but now serve as peaceful family companions.'),
|
80 |
+
('Dog', 'Italian_Greyhound', 'Small', '12-15 years', 'Sensitive, alert, playful', 'Moderate', False, 'Moderate', 'Low', 'Miniature sighthounds known for their elegant appearance and affectionate nature, Italian Greyhounds make excellent companion dogs.'),
|
81 |
+
('Dog', 'Japanese_Spaniel', 'Small', '10-12 years', 'Charming, noble, affectionate', 'Moderate', False, 'Low', 'High', 'Also known as the Japanese Chin, these small companion dogs have a distinctive flat face and were once favorites of Japanese nobility.'),
|
82 |
+
('Dog', 'Kerry_Blue_Terrier', 'Medium', '12-15 years', 'Alert, adaptable, people-oriented', 'High', True, 'High', 'High', 'Medium-sized terriers with a distinctive blue coat, known for their versatility and intelligence. Originally from County Kerry, Ireland, they were all-purpose farm dogs that evolved into capable working and companion animals.'),
|
83 |
+
('Dog', 'Labrador_Retriever', 'Large', '10-12 years', 'Friendly, outgoing, even-tempered', 'Moderate', True, 'High', 'Moderate', 'One of the most popular dog breeds, known for their friendly nature and excellent retrieving skills. Originally from Newfoundland, these versatile dogs excel as family companions, service dogs, and working retrievers.'),
|
84 |
+
('Dog', 'Lakeland_Terrier', 'Small', '12-16 years', 'Bold, friendly, confident', 'Moderate', True, 'High', 'High', 'Named after the Lake District in England, these terriers are sturdy and bold with a wiry coat. Developed to protect sheep from foxes, they remain confident and fearless while being adaptable family companions.'),
|
85 |
+
('Dog', 'Leonberg', 'Giant', '7-9 years', 'Gentle, friendly, intelligent', 'High', True, 'Moderate', 'High', 'Large, muscular dogs with a lion-like mane, known for their gentle nature and water rescue abilities. Created in the German town of Leonberg, these gentle giants combine strength with remarkable patience and grace.'),
|
86 |
+
('Dog', 'Lhasa', 'Small', '12-15 years', 'Confident, smart, comical', 'High', False, 'Low', 'High', 'Lhasa Apsos are small but sturdy dogs with a long, flowing coat. They were originally bred as indoor sentinel dogs in Buddhist monasteries.'),
|
87 |
+
('Dog', 'Maltese_Dog', 'Small', '12-15 years', 'Gentle, playful, charming', 'High', False, 'Low', 'High', 'Small, elegant dogs with long, silky white coats, known for their sweet and affectionate nature. Ancient breed of Mediterranean origin, they were cherished by nobles for centuries and remain adaptable, gentle companions.'),
|
88 |
+
('Dog', 'Mexican_Hairless', 'Varies', '12-15 years', 'Loyal, alert, cheerful', 'Moderate', True, 'Moderate', 'Low', 'Also known as the Xoloitzcuintli, these dogs come in three sizes and can be either hairless or coated, known for their ancient history in Mexico.'),
|
89 |
+
('Dog', 'Newfoundland', 'Giant', '8-10 years', 'Sweet, patient, devoted', 'High', True, 'Moderate', 'High', 'Large, strong dogs known for their water rescue abilities and gentle nature, especially with children. These powerful swimmers have a natural lifesaving instinct and are famous for their calm, noble temperament.'),
|
90 |
+
('Dog', 'Norfolk_Terrier', 'Small', '12-15 years', 'Fearless, spirited, companionable', 'Moderate', True, 'Moderate', 'Moderate', 'Small, sturdy terriers with a wiry coat, known for their playful and affectionate nature.'),
|
91 |
+
('Dog', 'Norwegian_Elkhound', 'Medium', '12-15 years', 'Bold, playful, loyal', 'High', True, 'High', 'High', 'Ancient Nordic breed known for their silver-gray coat and curled tail, originally used for hunting moose and other large game.'),
|
92 |
+
('Dog', 'Norwich_Terrier', 'Small', '12-15 years', 'Fearless, loyal, affectionate', 'Moderate', True, 'Moderate', 'Moderate', 'One of the smallest terriers, Norwich Terriers are hardy, fearless, and affectionate companions.'),
|
93 |
+
('Dog', 'Old_English_Sheepdog', 'Large', '10-12 years', 'Adaptable, gentle, intelligent', 'High', True, 'Moderate', 'High', 'Recognizable by their shaggy coat, Old English Sheepdogs are adaptable and good-natured. Once droving dogs of western England, they combine herding ability with a playful, protective nature toward their families.'),
|
94 |
+
('Dog', 'Pekinese', 'Small', '12-14 years', 'Affectionate, loyal, regal in manner', 'Moderate', False, 'Low', 'High', 'Also spelled Pekingese, these small dogs with flat faces and long coats were once sacred to Chinese royalty.'),
|
95 |
+
('Dog', 'Pembroke', 'Small', '12-15 years', 'Affectionate, intelligent, outgoing', 'Moderate', True, 'Moderate', 'Moderate', 'Known for their short legs and long bodies, Pembroke Welsh Corgis are herding dogs favored by the British royal family.'),
|
96 |
+
('Dog', 'Pomeranian', 'Small', '12-16 years', 'Lively, bold, inquisitive', 'Moderate', False, 'Low', 'High', 'Small, fluffy dogs with fox-like faces, known for their vivacious personalities and luxurious coats. Once larger sled dogs, these bred-down companions retain their bold spirit and were favored by royalty including Queen Victoria.'),
|
97 |
+
('Dog', 'Rhodesian_Ridgeback', 'Large', '10-12 years', 'Dignified, intelligent, strong-willed', 'Moderate', True, 'High', 'Low', 'Large, muscular dogs known for the ridge of hair along their backs, originally bred to hunt lions in Africa.'),
|
98 |
+
('Dog', 'Rottweiler', 'Large', '8-10 years', 'Loyal, loving, confident guardian', 'High', True, 'High', 'Low', 'Powerful and protective, Rottweilers are excellent guard dogs but also loving family companions when well-trained.'),
|
99 |
+
('Dog', 'Saint_Bernard', 'Giant', '8-10 years', 'Gentle, patient, friendly', 'High', True, 'Moderate', 'High', 'Known for their massive size and gentle nature, Saint Bernards were originally bred for rescue work in the Swiss Alps.'),
|
100 |
+
('Dog', 'Saluki', 'Large', '12-14 years', 'Gentle, dignified, independent-minded', 'High', True, 'High', 'Low', 'Ancient sighthounds known for their grace and speed, Salukis have a distinctive feathered coat and ears.'),
|
101 |
+
('Dog', 'Samoyed', 'Medium', '12-14 years', 'Friendly, gentle, adaptable', 'High', True, 'High', 'High', 'Beautiful white Arctic dogs known for their "smiling" expression and thick, fluffy coat. Originally bred for sledding and herding reindeer, they combine working dog capability with a warm, family-friendly nature.'),
|
102 |
+
('Dog', 'Scotch_Terrier', 'Small', '11-13 years', 'Independent, confident, spirited', 'Moderate', True, 'Moderate', 'High', 'Also known as the Scottish Terrier, these distinctive dogs with beards and eyebrows are known for their dignified, almost human-like personality.'),
|
103 |
+
('Dog', 'Scottish_Deerhound', 'Large', '8-11 years', 'Gentle, dignified, polite', 'High', True, 'High', 'Moderate', 'Large, wiry-coated sighthounds resembling Greyhounds, known for their gentle nature and hunting ability.'),
|
104 |
+
('Dog', 'Sealyham_Terrier', 'Small', '12-14 years', 'Alert, outgoing, calm', 'Moderate', True, 'Moderate', 'High', 'Originally bred for hunting, Sealyhams are now rare but make charming and sturdy companions. Developed in Wales to hunt badgers and otters, they combine terrier tenacity with a surprisingly calm demeanor.'),
|
105 |
+
('Dog', 'Shetland_Sheepdog', 'Small', '12-14 years', 'Playful, energetic, intelligent', 'High', True, 'High', 'High', 'Small herding dogs resembling miniature Collies, known for their intelligence and agility. Originally from the Shetland Islands, these "Shelties" excel in obedience, herding, and agility competitions while being devoted family companions.'),
|
106 |
+
('Dog', 'Shih-Tzu', 'Small', '10-16 years', 'Affectionate, playful, outgoing', 'High', True, 'Low', 'High', 'Small, affectionate companion dogs known for their long, silky coat and sweet personality. Originally bred for Chinese royalty, they are excellent lap dogs and adapt well to both city and suburban life.'),
|
107 |
+
('Dog', 'Siberian_Husky', 'Medium', '12-14 years', 'Outgoing, mischievous, loyal', 'High', True, 'Very High', 'Moderate', 'Beautiful sled dogs known for their striking blue eyes, thick coats, and wolf-like appearance. Originally bred by the Chukchi people of northeastern Asia, they combine endurance with a friendly, adventurous spirit.'),
|
108 |
+
('Dog', 'Staffordshire_Bullterrier', 'Medium', '12-14 years', 'Courageous, intelligent, loyal', 'Moderate', True, 'High', 'Low', 'Strong, muscular terriers known for their courage and affectionate nature, especially with children.'),
|
109 |
+
('Dog', 'Sussex_Spaniel', 'Medium', '11-13 years', 'Calm, friendly, merry', 'Moderate', True, 'Moderate', 'Moderate', 'Rare breed of spaniel known for their golden-liver coat and low-set body, originally bred for hunting.'),
|
110 |
+
('Dog', 'Tibetan_Mastiff', 'Large', '10-12 years', 'Independent, reserved, intelligent', 'High', False, 'Moderate', 'High', 'Ancient guardian breed known for their massive size and thick coat, Tibetan Mastiffs are independent and protective.'),
|
111 |
+
('Dog', 'Tibetan_Terrier', 'Medium', '12-15 years', 'Affectionate, sensitive, clever', 'High', True, 'Moderate', 'High', 'Not actually terriers, these dogs were bred in Tibet and are known for their profuse, long coat.'),
|
112 |
+
('Dog', 'Walker_Hound', 'Large', '12-13 years', 'Smart, brave, friendly', 'Moderate', True, 'High', 'Low', 'Also known as the Treeing Walker Coonhound, these dogs are excellent hunters with a distinctive bark. Developed in Kentucky from Virginia Hounds, they are renowned for their speed, endurance, and melodious voice.'),
|
113 |
+
('Dog', 'Weimaraner', 'Large', '10-13 years', 'Friendly, fearless, obedient', 'High', True, 'High', 'Low', 'Known as the "Gray Ghost," Weimaraners are athletic and intelligent dogs with a distinctive silver-gray coat.'),
|
114 |
+
('Dog', 'Welsh_Springer_Spaniel', 'Medium', '12-15 years', 'Active, loyal, affectionate', 'High', True, 'High', 'Moderate', 'Similar to English Springers but with a distinctive red and white coat, Welsh Springers are devoted and energetic.'),
|
115 |
+
('Dog', 'West_Highland_White_Terrier', 'Small', '12-16 years', 'Friendly, hardy, confident', 'Moderate', True, 'Moderate', 'High', 'Commonly known as "Westies," these white terriers are friendly and sturdy with a bright personality.'),
|
116 |
+
('Dog', 'Yorkshire_Terrier', 'Small', '13-16 years', 'Affectionate, sprightly, tomboyish', 'High', False, 'Moderate', 'High', 'Popular toy breed known for their long silky coat and feisty personality. Despite their small size, they maintain a brave terrier spirit and were originally bred as ratters in Yorkshire mills.'),
|
117 |
+
('Dog', 'Affenpinscher', 'Small', '12-15 years', 'Confident, amusing, stubborn', 'Moderate', False, 'Moderate', 'Moderate', 'Small terrier-like toys known as "monkey dogs" due to their distinctive facial appearance.'),
|
118 |
+
('Dog', 'Basenji', 'Small', '12-16 years', 'Independent, smart, poised', 'Moderate', False, 'High', 'Low', 'Ancient African breed known for their inability to bark, instead making a unique yodel-like sound. Called "the barkless dog," they are intelligent hunters with cat-like cleanliness and independent nature.'),
|
119 |
+
('Dog', 'Basset', 'Medium', '10-12 years', 'Patient, low-key, charming', 'Moderate', True, 'Low', 'Moderate', 'Short-legged, long-bodied hounds known for their excellent sense of smell and gentle dispositions. Second only to Bloodhounds in scenting ability, these French-origin dogs combine persistence with a sweet, patient nature.'),
|
120 |
+
('Dog', 'Beagle', 'Small', '12-15 years', 'Merry, friendly, curious', 'Moderate', True, 'High', 'Low', 'Small hound dogs known for their excellent sense of smell and friendly, outgoing personalities. Popular family pets and skilled scent hunters, famous for their melodious bay and pack mentality.'),
|
121 |
+
('Dog', 'Black-and-Tan_Coonhound', 'Large', '10-12 years', 'Even-tempered, easygoing, friendly', 'Moderate', True, 'High', 'Low', 'Large, powerful scent hounds known for their distinctive black and tan coloration and melodious bay.'),
|
122 |
+
('Dog', 'Bloodhound', 'Large', '10-12 years', 'Gentle, patient, stubborn', 'High', True, 'Moderate', 'Moderate', 'Known for their exceptional sense of smell, Bloodhounds are large, gentle dogs often used in tracking.'),
|
123 |
+
('Dog', 'Bluetick', 'Large', '11-12 years', 'Friendly, intelligent, active', 'Moderate', True, 'High', 'Low', 'Known for their mottled blue coat, Bluetick Coonhounds are skilled hunting dogs with a keen sense of smell and a melodious howl.'),
|
124 |
+
('Dog', 'Borzoi', 'Large', '10-12 years', 'Quiet, gentle, athletic', 'High', True, 'Moderate', 'High', 'Also known as Russian Wolfhounds, Borzois are elegant sighthounds known for their silky coat and graceful demeanor.'),
|
125 |
+
('Dog', 'Boxer', 'Large', '10-12 years', 'Fun-loving, bright, active', 'Moderate', True, 'High', 'Low', 'Playful and energetic, Boxers are known for their patient and protective nature with children. Originally developed in Germany as working dogs, they combine strength with a uniquely playful and clownish personality.'),
|
126 |
+
('Dog', 'Briard', 'Large', '10-12 years', 'Confident, smart, loyal', 'High', True, 'High', 'High', 'Large French herding dogs with a distinctive long, wavy coat, Briards are loyal and protective. Known as "hearts wrapped in fur," they served as WWI sentries and now excel as both working dogs and devoted family guardians.'),
|
127 |
+
('Dog', 'Bull_mastiff', 'Large', '8-10 years', 'Affectionate, loyal, quiet', 'Moderate', True, 'Moderate', 'Low', 'Large, powerful dogs originally bred to guard estates, Bullmastiffs are gentle giants with a calm demeanor.'),
|
128 |
+
('Dog', 'Cairn', 'Small', '13-15 years', 'Alert, cheerful, busy', 'Moderate', True, 'Moderate', 'Moderate', 'Small, rugged terriers known for their shaggy coat and lively personality. Originally bred to hunt in the Scottish Highlands, these hardy dogs are intelligent and make excellent watchdogs despite their small size.'),
|
129 |
+
('Dog', 'Chow', 'Medium', '8-12 years', 'Aloof, loyal, quiet', 'High', False, 'Low', 'High', 'Ancient Chinese breed known for their lion-like mane and blue-black tongues. Independent and dignified, they make excellent watchdogs but require early socialization.'),
|
130 |
+
('Dog', 'Clumber', 'Large', '10-12 years', 'Gentle, loyal, thoughtful', 'Moderate', True, 'Moderate', 'High', 'The largest of the spaniels, Clumbers are known for their distinctive white coat and calm demeanor. Developed in France and England, these dignified hunters combine power with a methodical hunting style and gentle nature.'),
|
131 |
+
('Dog', 'Cocker_Spaniel', 'Small', '10-14 years', 'Gentle, smart, happy', 'High', True, 'Moderate', 'High', 'Known for their long, silky ears and expressive eyes, Cockers are popular family dogs with a merry disposition.'),
|
132 |
+
('Dog', 'Collie', 'Large', '10-14 years', 'Devoted, graceful, proud', 'High', True, 'High', 'High', 'Made famous by "Lassie," Collies are intelligent herding dogs known for their loyalty and grace. Their remarkable intuition and gentle nature make them exceptional family guardians, especially with children.'),
|
133 |
+
('Dog', 'Curly-Coated_Retriever', 'Large', '10-12 years', 'Confident, independent, intelligent', 'Moderate', True, 'High', 'Low', 'Sporting dogs with a distinctive curly coat, known for their excellent swimming and retrieving abilities.'),
|
134 |
+
('Dog', 'Dhole', 'Medium', '10-13 years', 'Social, intelligent, athletic', 'High', False, 'High', 'Low', 'Also known as the Asiatic wild dog, Dholes are not typically kept as pets but are important in Asian ecosystems.'),
|
135 |
+
('Dog', 'Dingo', 'Medium', '10-13 years', 'Independent, intelligent, alert', 'High', False, 'High', 'Low', 'Native wild dogs of Australia, dingoes are not typically kept as pets and are important to the Australian ecosystem.'),
|
136 |
+
('Dog', 'Flat-Coated_Retriever', 'Large', '8-10 years', 'Optimistic, good-humored, outgoing', 'High', True, 'Very High', 'Moderate', 'Known for their shiny black or liver-colored coat, Flat-coated Retrievers are energetic and playful, excelling in both hunting and family life.'),
|
137 |
+
('Dog', 'Giant_Schnauzer', 'Large', '10-12 years', 'Loyal, intelligent, powerful', 'High', True, 'High', 'High', 'Large and powerful, Giant Schnauzers were originally bred as working dogs and require plenty of exercise.'),
|
138 |
+
('Dog', 'Golden_Retriever', 'Large', '10-12 years', 'Intelligent, friendly, devoted', 'High', True, 'High', 'High', 'Beautiful, golden-coated dogs known for their gentle nature and excellence in various roles. Popular as family companions, therapy dogs, and service animals, they excel in both work and companionship with their eager-to-please attitude.'),
|
139 |
+
('Dog', 'Groenendael', 'Large', '10-12 years', 'Intelligent, protective, loyal', 'High', True, 'High', 'High', 'The black variety of Belgian Shepherd, Groenendaels are intelligent working dogs with a long, black coat. Named after their village of origin, they excel in police work, herding, and as vigilant family guardians.'),
|
140 |
+
('Dog', 'Keeshond', 'Medium', '12-15 years', 'Friendly, lively, outgoing', 'Moderate', True, 'Moderate', 'High', 'Distinctive "spectacles" marking around their eyes, Keeshonds are fluffy, fox-like dogs known for their friendly and affectionate nature.'),
|
141 |
+
('Dog', 'Kelpie', 'Medium', '10-13 years', 'Intelligent, energetic, loyal', 'High', True, 'Very High', 'Low', 'Australian herding dogs known for their incredible work ethic and agility. Developed to work in harsh outback conditions, they are renowned for their ability to herd from above, often running across the backs of sheep in large flocks.'),
|
142 |
+
('Dog', 'Komondor', 'Large', '10-12 years', 'Steady, fearless, affectionate', 'High', True, 'Moderate', 'High', 'Large Hungarian sheepdogs known for their distinctive corded white coat, resembling dreadlocks. Their unique coat once helped them blend in with sheep flocks while protecting them from wolves.'),
|
143 |
+
('Dog', 'Kuvasz', 'Large', '10-12 years', 'Protective, loyal, patient', 'High', True, 'Moderate', 'High', 'Large, white guardian dogs from Hungary, Kuvaszok are protective of their families and independent. Once royal guards of Hungarian nobility, they combine impressive strength with natural protective instincts.'),
|
144 |
+
('Dog', 'Malamute', 'Large', '10-12 years', 'Affectionate, loyal, playful', 'High', True, 'Very High', 'High', 'Large, powerful sled dogs with thick coats, known for their strength and endurance. Originally bred by the Mahlemut tribe for hauling heavy loads in arctic conditions, they combine impressive power with a friendly, family-oriented nature.'),
|
145 |
+
('Dog', 'Malinois', 'Medium', '12-14 years', 'Confident, smart, hardworking', 'High', True, 'High', 'Moderate', 'One of four varieties of Belgian Shepherd, known for their intelligence and use in police and military work.'),
|
146 |
+
('Dog', 'Miniature_Pinscher', 'Small', '12-16 years', 'Fearless, energetic, alert', 'Moderate', False, 'Moderate', 'Low', 'Often called King of Toys, Miniature Pinschers are small, energetic dogs with a big personality. Despite their small size, these fearless dogs possess proud carriage and spirited animation.'),
|
147 |
+
('Dog', 'Miniature_Poodle', 'Small', '12-15 years', 'Intelligent, active, alert', 'High', True, 'Moderate', 'High', 'Smaller version of the Standard Poodle, known for their intelligence and hypoallergenic coat. Popular show dogs and companions, they retain their larger relatives high intelligence while being more adaptable to city living.'),
|
148 |
+
('Dog', 'Miniature_Schnauzer', 'Small', '12-15 years', 'Friendly, smart, obedient', 'Moderate', True, 'Moderate', 'High', 'The smallest of the Schnauzer breeds, known for their distinctive beard and eyebrows. Originally ratters and farm dogs, they combine intelligence with a spunky personality, making excellent watchdogs and family companions.'),
|
149 |
+
('Dog', 'Otterhound', 'Large', '10-13 years', 'Friendly, boisterous, even-tempered', 'High', True, 'High', 'High', 'Large, shaggy-coated hounds originally bred for hunting otters, now a rare breed. Known for their strong swimming ability and powerful nose, with less than 1000 remaining worldwide, making them rarer than giant pandas.'),
|
150 |
+
('Dog', 'Papillon', 'Small', '13-15 years', 'Happy, alert, friendly', 'Moderate', True, 'Moderate', 'Moderate', 'Small, elegant dogs known for their butterfly-like ears and lively personalities. Despite their delicate appearance, they are surprisingly athletic and intelligent, ranking among the top 10 smartest dog breeds. Also called the Continental Toy Spaniel.'),
|
151 |
+
('Dog', 'Pug', 'Small', '12-15 years', 'Charming, mischievous, loving', 'Moderate', True, 'Low', 'Moderate', 'Small, wrinkly-faced dogs known for their charming personality and comical expression. Once favored by Chinese emperors, these "multum in parvo" (much in little) dogs are excellent companions but need attention to their breathing and temperature regulation.'),
|
152 |
+
('Dog', 'Redbone', 'Large', '10-12 years', 'Even-tempered, amiable, eager to please', 'Moderate', True, 'High', 'Low', 'Known for their solid red coat, Redbone Coonhounds are athletic, warm-hearted dogs originally bred for hunting. Developed in the American South, they excel at tracking and treeing with remarkable stamina and a melodious voice.'),
|
153 |
+
('Dog', 'Schipperke', 'Small', '13-15 years', 'Confident, alert, curious', 'Moderate', True, 'Moderate', 'Moderate', 'Small, black dogs with a fox-like face, Schipperkes are known for their distinctive ruff and small, pointed ears. Originally Belgian barge dogs, these little captains earned their name as boat watchdogs and ratters.'),
|
154 |
+
('Dog', 'Silky_terrier', 'Small', '12-15 years', 'Friendly, quick, alert', 'Moderate', False, 'Moderate', 'High', 'Similar to Yorkshire Terriers but larger, Silky Terriers are playful and enjoy being part of family activities. Developed in Australia, they combine the refinement of toy dogs with the sturdy nature of working terriers.'),
|
155 |
+
('Dog', 'Soft-Coated_Wheaten_Terrier', 'Medium', '12-14 years', 'Happy, steady, self-confident', 'High', True, 'High', 'High', 'Known for their soft, wheat-colored coat and friendly demeanor, they make great family dogs. Developed in Ireland as farm dogs, they combined versatility in herding and hunting with a uniquely soft coat unlike other terriers.'),
|
156 |
+
('Dog', 'Standard_Poodle', 'Large', '10-18 years', 'Intelligent, active, dignified', 'High', True, 'High', 'High', 'Highly intelligent and elegant dogs, known for their hypoallergenic coat and versatility in various dog sports.'),
|
157 |
+
('Dog', 'Standard_Schnauzer', 'Medium', '13-16 years', 'Friendly, intelligent, obedient', 'High', True, 'High', 'High', 'The original Schnauzer breed, known for their distinctive beard and eyebrows and versatile working abilities.'),
|
158 |
+
('Dog', 'Toy_Poodle', 'Small', '12-18 years', 'Intelligent, lively, playful', 'High', True, 'Moderate', 'High', 'The smallest variety of Poodle, known for their intelligence, agility, and hypoallergenic coat. Despite their diminutive size, they retain the intelligence and athletic ability of their larger relatives.'),
|
159 |
+
('Dog', 'Toy_Terrier', 'Small', '12-16 years', 'Lively, bold, intelligent', 'Moderate', False, 'Moderate', 'Low', 'A general term for small terrier breeds, often referring to breeds like the English Toy Terrier or Toy Fox Terrier.'),
|
160 |
+
('Dog', 'Vizsla', 'Medium', '10-14 years', 'Affectionate, energetic, gentle', 'High', True, 'High', 'Low', 'Known for their golden-rust coat, Vizslas are versatile hunters and loving family companions. These Hungarian pointers are often called "velcro dogs" for their strong desire to stay close to their owners.'),
|
161 |
+
('Dog', 'Whippet', 'Medium', '12-15 years', 'Gentle, affectionate, quiet', 'Low', True, 'High', 'Low', 'Slender, athletic sighthounds known for their speed - capable of reaching 35mph. Despite high exercise needs, they are calm indoor companions and excellent apartment dogs.'),
|
162 |
+
('Dog', 'Wire-Haired_Fox_Terrier', 'Small', '12-15 years', 'Alert, confident, gregarious', 'High', True, 'High', 'High', 'Energetic and wire-coated, these terriers were originally bred for fox hunting. Their tough, dense coat and fearless nature made them ideal for flushing foxes from their dens, and they remain bold and spirited companions.'),
|
163 |
+
]
|
164 |
+
|
165 |
+
cursor.executemany('''
|
166 |
+
INSERT INTO AnimalCatalog (Species, Breed, Size_Category, Typical_Lifespan, Temperament, Care_Level, Good_With_Children, Exercise_Needs, Grooming_Needs, Brief_Description)
|
167 |
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
168 |
+
''', dog_data)
|
169 |
+
|
170 |
+
conn.commit()
|
171 |
+
cursor.close()
|
172 |
+
conn.close()
|
173 |
+
|
174 |
+
def get_dog_description(breed):
|
175 |
+
try:
|
176 |
+
conn = sqlite3.connect('animal_detector.db')
|
177 |
+
cursor = conn.cursor()
|
178 |
+
|
179 |
+
breed_name = breed.split('(')[0].strip()
|
180 |
+
|
181 |
+
cursor.execute("""
|
182 |
+
SELECT * FROM AnimalCatalog
|
183 |
+
WHERE Breed = ? OR Breed LIKE ? OR Breed LIKE ?
|
184 |
+
""", (breed_name, f"{breed_name}%", f"%{breed_name}"))
|
185 |
+
|
186 |
+
result = cursor.fetchone()
|
187 |
+
|
188 |
+
cursor.close()
|
189 |
+
conn.close()
|
190 |
+
|
191 |
+
if result:
|
192 |
+
# 標準化運動需求值
|
193 |
+
exercise_needs = result[8]
|
194 |
+
normalized_exercise = exercise_needs.strip().title()
|
195 |
+
if normalized_exercise not in ["Very High", "High", "Moderate", "Low"]:
|
196 |
+
normalized_exercise = "High" # 預設值
|
197 |
+
|
198 |
+
description = {
|
199 |
+
"Breed": result[2],
|
200 |
+
"Size": result[3],
|
201 |
+
"Lifespan": result[4],
|
202 |
+
"Temperament": result[5],
|
203 |
+
"Care Level": result[6],
|
204 |
+
"Good with Children": "Yes" if result[7] else "No",
|
205 |
+
"Exercise Needs": normalized_exercise,
|
206 |
+
"Grooming Needs": result[9],
|
207 |
+
"Description": result[10]
|
208 |
+
}
|
209 |
+
return description
|
210 |
+
else:
|
211 |
+
print(f"No data found for breed: {breed_name}")
|
212 |
+
return None
|
213 |
+
|
214 |
+
except Exception as e:
|
215 |
+
print(f"Error in get_dog_description: {str(e)}")
|
216 |
+
return None
|
217 |
+
|
218 |
+
insert_dog_data()
|
219 |
+
|
220 |
+
|
221 |
+
@dataclass
|
222 |
+
class UserPreferences:
|
223 |
+
"""使用者偏好設定的資料結構"""
|
224 |
+
living_space: str # "apartment", "house_small", "house_large"
|
225 |
+
exercise_time: int # minutes per day
|
226 |
+
grooming_commitment: str # "low", "medium", "high"
|
227 |
+
experience_level: str # "beginner", "intermediate", "advanced"
|
228 |
+
has_children: bool
|
229 |
+
noise_tolerance: str # "low", "medium", "high"
|
230 |
+
space_for_play: bool
|
231 |
+
other_pets: bool
|
232 |
+
climate: str # "cold", "moderate", "hot"
|
233 |
+
|
234 |
+
|
235 |
+
def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences) -> dict:
|
236 |
+
"""計算品種與使用者條件的相容性分數"""
|
237 |
+
scores = {}
|
238 |
+
try:
|
239 |
+
# 1. 空間相容性計算
|
240 |
+
def calculate_space_score(size, living_space, has_yard):
|
241 |
+
base_scores = {
|
242 |
+
"Small": {"apartment": 0.95, "house_small": 1.0, "house_large": 0.90},
|
243 |
+
"Medium": {"apartment": 0.65, "house_small": 0.90, "house_large": 1.0},
|
244 |
+
"Large": {"apartment": 0.35, "house_small": 0.75, "house_large": 1.0},
|
245 |
+
"Giant": {"apartment": 0.15, "house_small": 0.55, "house_large": 1.0}
|
246 |
+
}
|
247 |
+
|
248 |
+
base_score = base_scores.get(size, base_scores["Medium"])[living_space]
|
249 |
+
adjustments = 0
|
250 |
+
|
251 |
+
# 特殊情況調整
|
252 |
+
if living_space == "apartment":
|
253 |
+
if size == "Small":
|
254 |
+
adjustments += 0.05
|
255 |
+
elif size in ["Large", "Giant"]:
|
256 |
+
adjustments -= 0.15
|
257 |
+
|
258 |
+
if has_yard and living_space in ["house_small", "house_large"]:
|
259 |
+
adjustments += 0.05
|
260 |
+
|
261 |
+
return min(1.0, max(0, base_score + adjustments))
|
262 |
+
|
263 |
+
# 2. 運動相容性計算
|
264 |
+
def calculate_exercise_score(breed_exercise_needs, user_exercise_time):
|
265 |
+
exercise_needs = {
|
266 |
+
'VERY HIGH': 120,
|
267 |
+
'HIGH': 90,
|
268 |
+
'MODERATE': 60,
|
269 |
+
'LOW': 30,
|
270 |
+
'VARIES': 60
|
271 |
+
}
|
272 |
+
|
273 |
+
breed_need = exercise_needs.get(breed_exercise_needs.strip().upper(), 60)
|
274 |
+
difference = abs(user_exercise_time - breed_need) / breed_need
|
275 |
+
|
276 |
+
if difference == 0:
|
277 |
+
return 1.0
|
278 |
+
elif difference <= 0.2:
|
279 |
+
return 0.95
|
280 |
+
elif difference <= 0.4:
|
281 |
+
return 0.85
|
282 |
+
elif difference <= 0.6:
|
283 |
+
return 0.70
|
284 |
+
elif difference <= 0.8:
|
285 |
+
return 0.50
|
286 |
+
else:
|
287 |
+
return 0.30
|
288 |
+
|
289 |
+
# 3. 美容需求計算
|
290 |
+
def calculate_grooming_score(breed_grooming_needs, user_commitment, breed_size):
|
291 |
+
base_scores = {
|
292 |
+
"High": {"low": 0.3, "medium": 0.7, "high": 1.0},
|
293 |
+
"Moderate": {"low": 0.5, "medium": 0.9, "high": 1.0},
|
294 |
+
"Low": {"low": 1.0, "medium": 0.95, "high": 0.9}
|
295 |
+
}
|
296 |
+
|
297 |
+
base_score = base_scores.get(breed_grooming_needs, base_scores["Moderate"])[user_commitment]
|
298 |
+
|
299 |
+
if breed_size == "Large" and user_commitment == "low":
|
300 |
+
base_score *= 0.80
|
301 |
+
elif breed_size == "Giant" and user_commitment == "low":
|
302 |
+
base_score *= 0.70
|
303 |
+
|
304 |
+
return base_score
|
305 |
+
|
306 |
+
# 4. 經驗等級計算
|
307 |
+
def calculate_experience_score(care_level, user_experience, temperament):
|
308 |
+
base_scores = {
|
309 |
+
"High": {"beginner": 0.3, "intermediate": 0.7, "advanced": 1.0},
|
310 |
+
"Moderate": {"beginner": 0.6, "intermediate": 0.9, "advanced": 1.0},
|
311 |
+
"Low": {"beginner": 0.9, "intermediate": 1.0, "advanced": 1.0}
|
312 |
+
}
|
313 |
+
|
314 |
+
score = base_scores.get(care_level, base_scores["Moderate"])[user_experience]
|
315 |
+
|
316 |
+
temperament_lower = temperament.lower()
|
317 |
+
if user_experience == "beginner":
|
318 |
+
if any(trait in temperament_lower for trait in ['stubborn', 'independent', 'intelligent']):
|
319 |
+
score *= 0.80
|
320 |
+
if any(trait in temperament_lower for trait in ['easy', 'gentle', 'friendly']):
|
321 |
+
score *= 1.15
|
322 |
+
|
323 |
+
return min(1.0, score)
|
324 |
+
|
325 |
+
# 計算各項分數
|
326 |
+
scores['space'] = calculate_space_score(
|
327 |
+
breed_info['Size'],
|
328 |
+
user_prefs.living_space,
|
329 |
+
user_prefs.space_for_play
|
330 |
+
)
|
331 |
+
|
332 |
+
scores['exercise'] = calculate_exercise_score(
|
333 |
+
breed_info.get('Exercise Needs', 'Moderate'),
|
334 |
+
user_prefs.exercise_time
|
335 |
+
)
|
336 |
+
|
337 |
+
scores['grooming'] = calculate_grooming_score(
|
338 |
+
breed_info.get('Grooming Needs', 'Moderate'),
|
339 |
+
user_prefs.grooming_commitment.lower(),
|
340 |
+
breed_info['Size']
|
341 |
+
)
|
342 |
+
|
343 |
+
scores['experience'] = calculate_experience_score(
|
344 |
+
breed_info.get('Care Level', 'Moderate'),
|
345 |
+
user_prefs.experience_level,
|
346 |
+
breed_info.get('Temperament', '')
|
347 |
+
)
|
348 |
+
|
349 |
+
# 基礎權重
|
350 |
+
weights = {
|
351 |
+
'space': 0.30,
|
352 |
+
'exercise': 0.25,
|
353 |
+
'grooming': 0.15,
|
354 |
+
'experience': 0.30
|
355 |
+
}
|
356 |
+
|
357 |
+
# 基礎分數計算
|
358 |
+
base_score = sum(score * weights[category]
|
359 |
+
for category, score in scores.items()
|
360 |
+
if category != 'overall')
|
361 |
+
|
362 |
+
# 根據性格特徵調整
|
363 |
+
temperament = breed_info.get('Temperament', '').lower()
|
364 |
+
personality_bonus = 0
|
365 |
+
|
366 |
+
positive_traits = ['friendly', 'gentle', 'affectionate']
|
367 |
+
negative_traits = ['aggressive', 'stubborn', 'dominant']
|
368 |
+
|
369 |
+
personality_bonus += sum(0.02 for trait in positive_traits if trait in temperament)
|
370 |
+
personality_bonus -= sum(0.02 for trait in negative_traits if trait in temperament)
|
371 |
+
|
372 |
+
adjusted_score = round(base_score + personality_bonus, 4)
|
373 |
+
final_score = round(min(1.0, max(0, adjusted_score)), 4)
|
374 |
+
scores['overall'] = final_score
|
375 |
+
|
376 |
+
for key in ['space', 'exercise', 'grooming', 'experience']:
|
377 |
+
scores[key] = round(scores[key], 4)
|
378 |
+
|
379 |
+
return scores
|
380 |
+
|
381 |
+
except Exception as e:
|
382 |
+
print(f"Error in calculate_compatibility_score: {str(e)}")
|
383 |
+
return {
|
384 |
+
'space': 0.5,
|
385 |
+
'exercise': 0.5,
|
386 |
+
'grooming': 0.5,
|
387 |
+
'experience': 0.5,
|
388 |
+
'overall': 0.5
|
389 |
+
}
|
390 |
+
|
391 |
+
|
392 |
+
def get_breed_recommendations(user_prefs: UserPreferences, top_n: int = 5) -> List[Dict]:
|
393 |
+
"""基於使用者偏好推薦狗品種,確保正確的分數排序"""
|
394 |
+
recommendations = []
|
395 |
+
seen_breeds = set()
|
396 |
+
|
397 |
+
try:
|
398 |
+
# 獲取所有品種
|
399 |
+
conn = sqlite3.connect('animal_detector.db')
|
400 |
+
cursor = conn.cursor()
|
401 |
+
cursor.execute("SELECT Breed FROM AnimalCatalog")
|
402 |
+
all_breeds = cursor.fetchall()
|
403 |
+
conn.close()
|
404 |
+
|
405 |
+
# 收集所有品種的分數
|
406 |
+
for breed_tuple in all_breeds:
|
407 |
+
breed = breed_tuple[0]
|
408 |
+
base_breed = breed.split('(')[0].strip()
|
409 |
+
|
410 |
+
# 避免重複品種
|
411 |
+
if base_breed in seen_breeds:
|
412 |
+
continue
|
413 |
+
seen_breeds.add(base_breed)
|
414 |
+
|
415 |
+
# 獲取品種資訊
|
416 |
+
breed_info = get_dog_description(breed)
|
417 |
+
if not isinstance(breed_info, dict):
|
418 |
+
continue
|
419 |
+
|
420 |
+
# 計算基礎相容性分數
|
421 |
+
compatibility_scores = calculate_compatibility_score(breed_info, user_prefs)
|
422 |
+
|
423 |
+
# 計算品種特定加分
|
424 |
+
breed_bonus = 0.0
|
425 |
+
|
426 |
+
# 1. 壽命加分
|
427 |
+
try:
|
428 |
+
lifespan = breed_info.get('Lifespan', '10-12 years')
|
429 |
+
years = [int(x) for x in lifespan.split('-')[0].split()[0:1]]
|
430 |
+
longevity_bonus = min(0.02, (max(years) - 10) * 0.005)
|
431 |
+
breed_bonus += longevity_bonus
|
432 |
+
except:
|
433 |
+
pass
|
434 |
+
|
435 |
+
# 2. 性格特徵加分
|
436 |
+
temperament = breed_info.get('Temperament', '').lower()
|
437 |
+
positive_traits = ['friendly', 'gentle', 'affectionate', 'intelligent']
|
438 |
+
negative_traits = ['aggressive', 'stubborn', 'dominant']
|
439 |
+
|
440 |
+
breed_bonus += sum(0.01 for trait in positive_traits if trait in temperament)
|
441 |
+
breed_bonus -= sum(0.01 for trait in negative_traits if trait in temperament)
|
442 |
+
|
443 |
+
# 3. 與孩童相容性加分
|
444 |
+
if user_prefs.has_children:
|
445 |
+
if breed_info.get('Good with Children') == 'Yes':
|
446 |
+
breed_bonus += 0.02
|
447 |
+
elif breed_info.get('Good with Children') == 'No':
|
448 |
+
breed_bonus -= 0.03
|
449 |
+
|
450 |
+
# 計算最終分數
|
451 |
+
breed_bonus = round(breed_bonus, 4)
|
452 |
+
final_score = round(compatibility_scores['overall'] + breed_bonus, 4)
|
453 |
+
|
454 |
+
recommendations.append({
|
455 |
+
'breed': breed,
|
456 |
+
'base_score': round(compatibility_scores['overall'], 4),
|
457 |
+
'bonus_score': round(breed_bonus, 4),
|
458 |
+
'final_score': final_score,
|
459 |
+
'scores': compatibility_scores,
|
460 |
+
'info': breed_info
|
461 |
+
})
|
462 |
+
|
463 |
+
# 嚴格按照 final_score 排序
|
464 |
+
recommendations.sort(key=lambda x: (round(-x['final_score'], 4), x['breed'] )) # 負號使其降序排列,並確保4位小數
|
465 |
+
|
466 |
+
# 選擇前N名並確保正確排序
|
467 |
+
final_recommendations = []
|
468 |
+
last_score = None
|
469 |
+
rank = 1
|
470 |
+
|
471 |
+
for rec in recommendations:
|
472 |
+
if len(final_recommendations) >= top_n:
|
473 |
+
break
|
474 |
+
|
475 |
+
current_score = rec['final_score']
|
476 |
+
|
477 |
+
# 確保分數遞減
|
478 |
+
if last_score is not None and current_score > last_score:
|
479 |
+
continue
|
480 |
+
|
481 |
+
# 添加排名資訊
|
482 |
+
rec['rank'] = rank
|
483 |
+
final_recommendations.append(rec)
|
484 |
+
|
485 |
+
last_score = current_score
|
486 |
+
rank += 1
|
487 |
+
|
488 |
+
# 驗證最終排序
|
489 |
+
for i in range(len(final_recommendations)-1):
|
490 |
+
current = final_recommendations[i]
|
491 |
+
next_rec = final_recommendations[i+1]
|
492 |
+
|
493 |
+
if current['final_score'] < next_rec['final_score']:
|
494 |
+
print(f"Warning: Sorting error detected!")
|
495 |
+
print(f"#{i+1} {current['breed']}: {current['final_score']}")
|
496 |
+
print(f"#{i+2} {next_rec['breed']}: {next_rec['final_score']}")
|
497 |
+
|
498 |
+
# 交換位置
|
499 |
+
final_recommendations[i], final_recommendations[i+1] = \
|
500 |
+
final_recommendations[i+1], final_recommendations[i]
|
501 |
+
|
502 |
+
# 打印最終結果以供驗證
|
503 |
+
print("\nFinal Rankings:")
|
504 |
+
for rec in final_recommendations:
|
505 |
+
print(f"#{rec['rank']} {rec['breed']}")
|
506 |
+
print(f"Base Score: {rec['base_score']:.4f}")
|
507 |
+
print(f"Bonus: {rec['bonus_score']:.4f}")
|
508 |
+
print(f"Final Score: {rec['final_score']:.4f}\n")
|
509 |
+
|
510 |
+
return final_recommendations
|
511 |
+
|
512 |
+
except Exception as e:
|
513 |
+
print(f"Error in get_breed_recommendations: {str(e)}")
|
514 |
+
print(f"Traceback: {traceback.format_exc()}")
|
515 |
+
return []
|
516 |
+
|
517 |
+
|
518 |
+
|
519 |
+
def calculate_breed_bonus(breed_info: dict, user_prefs: UserPreferences) -> float:
|
520 |
+
"""計算品種額外加分"""
|
521 |
+
bonus = 0.0
|
522 |
+
|
523 |
+
# 壽命加分
|
524 |
+
try:
|
525 |
+
lifespan = breed_info.get('Lifespan', '10-12 years')
|
526 |
+
years = [int(x) for x in lifespan.split('-')[0].split()[0:1]]
|
527 |
+
longevity_bonus = min(0.05, (max(years) - 10) * 0.01)
|
528 |
+
bonus += longevity_bonus
|
529 |
+
except:
|
530 |
+
pass
|
531 |
+
|
532 |
+
# 性格特徵加分
|
533 |
+
temperament = breed_info.get('Temperament', '').lower()
|
534 |
+
if user_prefs.has_children:
|
535 |
+
if 'gentle' in temperament or 'patient' in temperament:
|
536 |
+
bonus += 0.03
|
537 |
+
|
538 |
+
# 適應性加分
|
539 |
+
if breed_info.get('Size') == "Small" and user_prefs.living_space == "apartment":
|
540 |
+
bonus += 0.02
|
541 |
+
|
542 |
+
return bonus
|
543 |
+
|
544 |
+
def calculate_additional_factors(breed_info: dict, user_prefs: UserPreferences) -> dict:
|
545 |
+
"""計算額外的排序因素"""
|
546 |
+
factors = {
|
547 |
+
'versatility': 0.0,
|
548 |
+
'health_score': 0.0,
|
549 |
+
'adaptability': 0.0
|
550 |
+
}
|
551 |
+
|
552 |
+
# 計算多功能性分數
|
553 |
+
temperament = breed_info.get('Temperament', '').lower()
|
554 |
+
versatile_traits = ['intelligent', 'adaptable', 'versatile', 'trainable']
|
555 |
+
factors['versatility'] = sum(trait in temperament for trait in versatile_traits) / len(versatile_traits)
|
556 |
+
|
557 |
+
# 計算健康分數(基於預期壽命)
|
558 |
+
lifespan = breed_info.get('Lifespan', '10-12 years')
|
559 |
+
try:
|
560 |
+
years = [int(x) for x in lifespan.split('-')[0].split()[0:1]]
|
561 |
+
factors['health_score'] = min(1.0, max(years) / 15) # 標準化到0-1範圍
|
562 |
+
except:
|
563 |
+
factors['health_score'] = 0.5 # 預設值
|
564 |
+
|
565 |
+
# 計算適應性分數
|
566 |
+
size = breed_info.get('Size', 'Medium')
|
567 |
+
factors['adaptability'] = {
|
568 |
+
'Small': 0.9,
|
569 |
+
'Medium': 0.7,
|
570 |
+
'Large': 0.5,
|
571 |
+
'Giant': 0.3
|
572 |
+
}.get(size, 0.5)
|
573 |
+
|
574 |
+
return factors
|
575 |
+
|
576 |
+
def format_recommendation_html(recommendations: List[Dict]) -> str:
|
577 |
+
"""將推薦結果格式化為HTML,包含完整的分數說明與品種資訊,以及健康資訊"""
|
578 |
+
html_content = "<div class='recommendations-container'>"
|
579 |
+
|
580 |
+
for rec in recommendations:
|
581 |
+
breed = rec['breed']
|
582 |
+
scores = rec['scores']
|
583 |
+
info = rec['info']
|
584 |
+
rank = rec.get('rank', 0)
|
585 |
+
final_score = rec.get('final_score', scores['overall'])
|
586 |
+
bonus_score = rec.get('bonus_score', 0)
|
587 |
+
|
588 |
+
# 獲取健康資訊
|
589 |
+
health_info = breed_health_info.get(breed, {"health_notes": default_health_note})
|
590 |
+
|
591 |
+
# 收集加分原因
|
592 |
+
bonus_reasons = []
|
593 |
+
temperament = info.get('Temperament', '').lower()
|
594 |
+
if any(trait in temperament for trait in ['friendly', 'gentle', 'affectionate']):
|
595 |
+
bonus_reasons.append("Positive temperament traits")
|
596 |
+
if info.get('Good with Children') == 'Yes':
|
597 |
+
bonus_reasons.append("Excellent with children")
|
598 |
+
try:
|
599 |
+
lifespan = info.get('Lifespan', '10-12 years')
|
600 |
+
years = int(lifespan.split('-')[0])
|
601 |
+
if years > 12:
|
602 |
+
bonus_reasons.append("Above-average lifespan")
|
603 |
+
except:
|
604 |
+
pass
|
605 |
+
|
606 |
+
html_content += f"""
|
607 |
+
<div class="dog-info-card recommendation-card">
|
608 |
+
<div class="breed-info">
|
609 |
+
<h2 class="section-title">
|
610 |
+
<span class="icon">🏆</span> #{rank} {breed.replace('_', ' ')}
|
611 |
+
<span class="score-badge">
|
612 |
+
Overall Match: {final_score*100:.1f}%
|
613 |
+
</span>
|
614 |
+
</h2>
|
615 |
+
<div class="compatibility-scores">
|
616 |
+
<div class="score-item">
|
617 |
+
<span class="label">Space Compatibility:</span>
|
618 |
+
<div class="progress-bar">
|
619 |
+
<div class="progress" style="width: {scores['space']*100}%"></div>
|
620 |
+
</div>
|
621 |
+
<span class="percentage">{scores['space']*100:.1f}%</span>
|
622 |
+
</div>
|
623 |
+
<div class="score-item">
|
624 |
+
<span class="label">Exercise Match:</span>
|
625 |
+
<div class="progress-bar">
|
626 |
+
<div class="progress" style="width: {scores['exercise']*100}%"></div>
|
627 |
+
</div>
|
628 |
+
<span class="percentage">{scores['exercise']*100:.1f}%</span>
|
629 |
+
</div>
|
630 |
+
<div class="score-item">
|
631 |
+
<span class="label">Grooming Match:</span>
|
632 |
+
<div class="progress-bar">
|
633 |
+
<div class="progress" style="width: {scores['grooming']*100}%"></div>
|
634 |
+
</div>
|
635 |
+
<span class="percentage">{scores['grooming']*100:.1f}%</span>
|
636 |
+
</div>
|
637 |
+
<div class="score-item">
|
638 |
+
<span class="label">Experience Match:</span>
|
639 |
+
<div class="progress-bar">
|
640 |
+
<div class="progress" style="width: {scores['experience']*100}%"></div>
|
641 |
+
</div>
|
642 |
+
<span class="percentage">{scores['experience']*100:.1f}%</span>
|
643 |
+
</div>
|
644 |
+
{f'''
|
645 |
+
<div class="score-item bonus-score">
|
646 |
+
<span class="label">
|
647 |
+
Breed Bonus:
|
648 |
+
<span class="tooltip">
|
649 |
+
<span class="tooltip-icon">ⓘ</span>
|
650 |
+
<span class="tooltip-text">
|
651 |
+
<strong>Breed Bonus Points:</strong><br>
|
652 |
+
• {('<br>• '.join(bonus_reasons)) if bonus_reasons else 'No additional bonus points'}<br>
|
653 |
+
<br>
|
654 |
+
<strong>Bonus Factors Include:</strong><br>
|
655 |
+
• Friendly temperament<br>
|
656 |
+
• Child compatibility<br>
|
657 |
+
• Longer lifespan<br>
|
658 |
+
• Living space adaptability
|
659 |
+
</span>
|
660 |
+
</span>
|
661 |
+
</span>
|
662 |
+
<div class="progress-bar">
|
663 |
+
<div class="progress" style="width: {bonus_score*100}%"></div>
|
664 |
+
</div>
|
665 |
+
<span class="percentage">{bonus_score*100:.1f}%</span>
|
666 |
+
</div>
|
667 |
+
''' if bonus_score > 0 else ''}
|
668 |
+
</div>
|
669 |
+
<div class="breed-details-section">
|
670 |
+
<h3 class="subsection-title">
|
671 |
+
<span class="icon">📋</span> Breed Details
|
672 |
+
</h3>
|
673 |
+
<div class="details-grid">
|
674 |
+
<div class="detail-item">
|
675 |
+
<span class="tooltip">
|
676 |
+
<span class="icon">📏</span>
|
677 |
+
<span class="label">Size:</span>
|
678 |
+
<span class="tooltip-icon">ⓘ</span>
|
679 |
+
<span class="tooltip-text">
|
680 |
+
<strong>Size Categories:</strong><br>
|
681 |
+
• Small: Under 20 pounds<br>
|
682 |
+
• Medium: 20-60 pounds<br>
|
683 |
+
• Large: Over 60 pounds
|
684 |
+
</span>
|
685 |
+
<span class="value">{info['Size']}</span>
|
686 |
+
</span>
|
687 |
+
</div>
|
688 |
+
<div class="detail-item">
|
689 |
+
<span class="tooltip">
|
690 |
+
<span class="icon">🏃</span>
|
691 |
+
<span class="label">Exercise Needs:</span>
|
692 |
+
<span class="tooltip-icon">ⓘ</span>
|
693 |
+
<span class="tooltip-text">
|
694 |
+
<strong>Exercise Needs:</strong><br>
|
695 |
+
• Low: Short walks<br>
|
696 |
+
• Moderate: 1-2 hours daily<br>
|
697 |
+
• High: 2+ hours daily<br>
|
698 |
+
• Very High: Constant activity
|
699 |
+
</span>
|
700 |
+
<span class="value">{info['Exercise Needs']}</span>
|
701 |
+
</span>
|
702 |
+
</div>
|
703 |
+
<div class="detail-item">
|
704 |
+
<span class="tooltip">
|
705 |
+
<span class="icon">👨👩👧👦</span>
|
706 |
+
<span class="label">Good with Children:</span>
|
707 |
+
<span class="tooltip-icon">ⓘ</span>
|
708 |
+
<span class="tooltip-text">
|
709 |
+
<strong>Child Compatibility:</strong><br>
|
710 |
+
• Yes: Excellent with kids<br>
|
711 |
+
• Moderate: Good with older children<br>
|
712 |
+
• No: Better for adult households
|
713 |
+
</span>
|
714 |
+
<span class="value">{info['Good with Children']}</span>
|
715 |
+
</span>
|
716 |
+
</div>
|
717 |
+
</div>
|
718 |
+
</div>
|
719 |
+
<div class="description-section">
|
720 |
+
<h3 class="subsection-title">
|
721 |
+
<span class="icon">📝</span> Description
|
722 |
+
</h3>
|
723 |
+
<p class="description-text">{info.get('Description', '')}</p>
|
724 |
+
</div>
|
725 |
+
<div class="health-section">
|
726 |
+
<h3 class="subsection-title">
|
727 |
+
<span class="icon">🏥</span> Health Insights
|
728 |
+
<span class="tooltip">
|
729 |
+
<span class="tooltip-icon">ⓘ</span>
|
730 |
+
<span class="tooltip-text">
|
731 |
+
Health information is compiled from multiple sources including veterinary resources, breed guides, and international canine health databases.
|
732 |
+
Each dog is unique and may vary from these general guidelines.
|
733 |
+
</span>
|
734 |
+
</span>
|
735 |
+
</h3>
|
736 |
+
|
737 |
+
<div class="health-info">
|
738 |
+
<div class="health-details">
|
739 |
+
<h4>Common breed-specific health considerations :</h4>
|
740 |
+
<ul>
|
741 |
+
<li>Patellar luxation</li>
|
742 |
+
<li>Progressive retinal atrophy</li>
|
743 |
+
<li>Von Willebrand's disease</li>
|
744 |
+
<li>Open fontanel</li>
|
745 |
+
</ul>
|
746 |
+
|
747 |
+
<h4>Recommended health screenings:</h4>
|
748 |
+
<ul>
|
749 |
+
<li>Patella evaluation</li>
|
750 |
+
<li>Eye examination</li>
|
751 |
+
<li>Blood clotting tests</li>
|
752 |
+
<li>Skull development monitoring</li>
|
753 |
+
</ul>
|
754 |
+
</div>
|
755 |
+
</div>
|
756 |
+
|
757 |
+
<div class="health-disclaimer">
|
758 |
+
<p class="source">› Source: Compiled from various veterinary and breed information resources, 2024</p>
|
759 |
+
<p>› This information is for reference only and based on breed tendencies.</p>
|
760 |
+
<p>› Each dog is unique and may not develop any or all of these conditions.</p>
|
761 |
+
<p>› Always consult with qualified veterinarians for professional advice.</p>
|
762 |
+
</div>
|
763 |
+
</div>
|
764 |
+
<div class="action-section">
|
765 |
+
<a href="https://www.akc.org/dog-breeds/{breed.lower().replace('_', '-')}/"
|
766 |
+
target="_blank"
|
767 |
+
class="akc-button">
|
768 |
+
<span class="icon">🌐</span>
|
769 |
+
Learn more about {breed.replace('_', ' ')} on AKC website
|
770 |
+
</a>
|
771 |
+
</div>
|
772 |
+
</div>
|
773 |
+
</div>
|
774 |
+
"""
|
775 |
+
|
776 |
+
html_content += "</div>"
|
777 |
+
return html_content
|
history_manager.py
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from datetime import datetime
|
3 |
+
import json
|
4 |
+
import os
|
5 |
+
import pytz
|
6 |
+
import traceback
|
7 |
+
|
8 |
+
class UserHistoryManager:
|
9 |
+
def __init__(self):
|
10 |
+
"""初始化歷史紀錄管理器"""
|
11 |
+
self.history_file = "user_history.json"
|
12 |
+
print(f"Initializing UserHistoryManager with file: {os.path.abspath(self.history_file)}")
|
13 |
+
self._init_file()
|
14 |
+
|
15 |
+
def _init_file(self):
|
16 |
+
"""初始化JSON檔案"""
|
17 |
+
try:
|
18 |
+
if not os.path.exists(self.history_file):
|
19 |
+
print(f"Creating new history file: {self.history_file}")
|
20 |
+
with open(self.history_file, 'w', encoding='utf-8') as f:
|
21 |
+
json.dump([], f)
|
22 |
+
else:
|
23 |
+
print(f"History file exists: {self.history_file}")
|
24 |
+
# 驗證檔案內容
|
25 |
+
with open(self.history_file, 'r', encoding='utf-8') as f:
|
26 |
+
data = json.load(f)
|
27 |
+
print(f"Current history entries: {len(data)}")
|
28 |
+
except Exception as e:
|
29 |
+
print(f"Error in _init_file: {str(e)}")
|
30 |
+
print(traceback.format_exc())
|
31 |
+
|
32 |
+
|
33 |
+
def save_history(self, user_preferences: dict, results: list) -> bool:
|
34 |
+
"""儲存搜尋歷史"""
|
35 |
+
try:
|
36 |
+
# 調試輸出
|
37 |
+
print("\nSaving history:")
|
38 |
+
print("Results to save:", results)
|
39 |
+
|
40 |
+
history_entry = {
|
41 |
+
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
42 |
+
"preferences": user_preferences,
|
43 |
+
"results": results # 確保這裡包含完整的結果資訊
|
44 |
+
}
|
45 |
+
|
46 |
+
with open(self.history_file, 'r', encoding='utf-8') as f:
|
47 |
+
history = json.load(f)
|
48 |
+
|
49 |
+
# 添加新紀錄
|
50 |
+
history.append(history_entry)
|
51 |
+
|
52 |
+
# 限制保存最近的20筆記錄
|
53 |
+
if len(history) > 20:
|
54 |
+
history = history[-20:]
|
55 |
+
|
56 |
+
with open(self.history_file, 'w', encoding='utf-8') as f:
|
57 |
+
json.dump(history, f, ensure_ascii=False, indent=2)
|
58 |
+
|
59 |
+
return True
|
60 |
+
except Exception as e:
|
61 |
+
print(f"Error saving history: {str(e)}")
|
62 |
+
return False
|
63 |
+
|
64 |
+
def get_history(self) -> list:
|
65 |
+
"""獲取搜尋歷史"""
|
66 |
+
try:
|
67 |
+
print("Attempting to read history") # Debug
|
68 |
+
with open(self.history_file, 'r', encoding='utf-8') as f:
|
69 |
+
data = json.load(f)
|
70 |
+
print(f"Read {len(data)} history entries") # Debug
|
71 |
+
return data if isinstance(data, list) else []
|
72 |
+
except Exception as e:
|
73 |
+
print(f"Error reading history: {str(e)}")
|
74 |
+
print(traceback.format_exc())
|
75 |
+
return []
|
76 |
+
|
77 |
+
def clear_all_history(self) -> bool:
|
78 |
+
"""清除所有歷史紀錄"""
|
79 |
+
try:
|
80 |
+
print("Attempting to clear all history") # Debug
|
81 |
+
with open(self.history_file, 'w', encoding='utf-8') as f:
|
82 |
+
json.dump([], f)
|
83 |
+
print("History cleared successfully") # Debug
|
84 |
+
return True
|
85 |
+
except Exception as e:
|
86 |
+
print(f"Error clearing history: {str(e)}")
|
87 |
+
print(traceback.format_exc())
|
88 |
+
return False
|
search_history.py
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import traceback
|
3 |
+
from typing import Optional, Dict, List
|
4 |
+
from history_manager import UserHistoryManager
|
5 |
+
|
6 |
+
class SearchHistoryComponent:
|
7 |
+
def __init__(self):
|
8 |
+
"""初始化搜索歷史組件"""
|
9 |
+
self.history_manager = UserHistoryManager()
|
10 |
+
|
11 |
+
def format_history_html(self, history_data: Optional[List[Dict]] = None) -> str:
|
12 |
+
"""將歷史記錄格式化為HTML"""
|
13 |
+
try:
|
14 |
+
if history_data is None:
|
15 |
+
history_data = self.history_manager.get_history()
|
16 |
+
|
17 |
+
if not history_data:
|
18 |
+
return """
|
19 |
+
<div style='text-align: center; padding: 20px; color: #666;'>
|
20 |
+
No search history yet. Try making some breed recommendations!
|
21 |
+
</div>
|
22 |
+
"""
|
23 |
+
|
24 |
+
html = "<div class='history-container'>"
|
25 |
+
|
26 |
+
for entry in reversed(history_data):
|
27 |
+
timestamp = entry.get('timestamp', 'Unknown time')
|
28 |
+
prefs = entry.get('preferences', {})
|
29 |
+
results = entry.get('results', [])
|
30 |
+
|
31 |
+
html += f"""
|
32 |
+
<div class="history-entry">
|
33 |
+
<div class="history-header">
|
34 |
+
<span class="timestamp">🕒 {timestamp}</span>
|
35 |
+
</div>
|
36 |
+
|
37 |
+
<div class="params-list">
|
38 |
+
<h4>Search Parameters:</h4>
|
39 |
+
<ul>
|
40 |
+
<li><span class="param-label">Living Space:</span> {prefs.get('living_space', 'N/A')}</li>
|
41 |
+
<li><span class="param-label">Exercise Time:</span> {prefs.get('exercise_time', 'N/A')} minutes</li>
|
42 |
+
<li><span class="param-label">Grooming:</span> {prefs.get('grooming_commitment', 'N/A')}</li>
|
43 |
+
<li><span class="param-label">Experience:</span> {prefs.get('experience_level', 'N/A')}</li>
|
44 |
+
<li><span class="param-label">Children at Home:</span> {"Yes" if prefs.get('has_children') else "No"}</li>
|
45 |
+
<li><span class="param-label">Noise Tolerance:</span> {prefs.get('noise_tolerance', 'N/A')}</li>
|
46 |
+
</ul>
|
47 |
+
</div>
|
48 |
+
|
49 |
+
<div class="results-list">
|
50 |
+
<h4>Top 5 Breed Matches:</h4>
|
51 |
+
<div class="breed-list">
|
52 |
+
"""
|
53 |
+
|
54 |
+
if results:
|
55 |
+
for i, result in enumerate(results[:5], 1):
|
56 |
+
breed_name = result.get('breed', 'Unknown breed').replace('_', ' ')
|
57 |
+
score = result.get('overall_score', result.get('final_score', 0))
|
58 |
+
html += f"""
|
59 |
+
<div class="breed-item">
|
60 |
+
<div class="breed-info">
|
61 |
+
<span class="breed-rank">#{i}</span>
|
62 |
+
<span class="breed-name">{breed_name}</span>
|
63 |
+
<span class="breed-score">{score*100:.1f}%</span>
|
64 |
+
</div>
|
65 |
+
</div>
|
66 |
+
"""
|
67 |
+
|
68 |
+
html += """
|
69 |
+
</div>
|
70 |
+
</div>
|
71 |
+
</div>
|
72 |
+
"""
|
73 |
+
|
74 |
+
html += "</div>"
|
75 |
+
return html
|
76 |
+
|
77 |
+
except Exception as e:
|
78 |
+
print(f"Error formatting history: {str(e)}")
|
79 |
+
print(traceback.format_exc())
|
80 |
+
return f"""
|
81 |
+
<div style='text-align: center; padding: 20px; color: #dc2626;'>
|
82 |
+
Error formatting history. Please try refreshing the page.
|
83 |
+
<br>Error details: {str(e)}
|
84 |
+
</div>
|
85 |
+
"""
|
86 |
+
|
87 |
+
def clear_history(self) -> str:
|
88 |
+
"""清除所有搜尋歷史"""
|
89 |
+
try:
|
90 |
+
success = self.history_manager.clear_all_history()
|
91 |
+
print(f"Clear history result: {success}")
|
92 |
+
return self.format_history_html()
|
93 |
+
except Exception as e:
|
94 |
+
print(f"Error in clear_history: {str(e)}")
|
95 |
+
print(traceback.format_exc())
|
96 |
+
return "Error clearing history"
|
97 |
+
|
98 |
+
def refresh_history(self) -> str:
|
99 |
+
"""刷新歷史記錄顯示"""
|
100 |
+
try:
|
101 |
+
return self.format_history_html()
|
102 |
+
except Exception as e:
|
103 |
+
print(f"Error in refresh_history: {str(e)}")
|
104 |
+
return "Error refreshing history"
|
105 |
+
|
106 |
+
def save_search(self, user_preferences: dict, results: list) -> bool:
|
107 |
+
"""保存搜索結果"""
|
108 |
+
return self.history_manager.save_history(user_preferences, results)
|
109 |
+
|
110 |
+
def create_history_tab() -> None:
|
111 |
+
"""創建歷史記錄標籤頁"""
|
112 |
+
history_component = SearchHistoryComponent()
|
113 |
+
|
114 |
+
with gr.TabItem("Recommendation Search History"):
|
115 |
+
gr.HTML("""
|
116 |
+
<div style='text-align: center; padding: 20px;'>
|
117 |
+
<h3 style='color: #2D3748; margin-bottom: 10px;'>Search History</h3>
|
118 |
+
<p style='color: #4A5568;'>View your previous breed recommendations and search preferences</p>
|
119 |
+
</div>
|
120 |
+
""")
|
121 |
+
|
122 |
+
with gr.Row():
|
123 |
+
with gr.Column(scale=4):
|
124 |
+
history_display = gr.HTML()
|
125 |
+
|
126 |
+
with gr.Row():
|
127 |
+
with gr.Column(scale=1):
|
128 |
+
clear_history_btn = gr.Button(
|
129 |
+
"🗑️ Clear History",
|
130 |
+
variant="secondary",
|
131 |
+
size="sm"
|
132 |
+
)
|
133 |
+
with gr.Column(scale=1):
|
134 |
+
refresh_btn = gr.Button(
|
135 |
+
"🔄 Refresh",
|
136 |
+
variant="secondary",
|
137 |
+
size="sm"
|
138 |
+
)
|
139 |
+
|
140 |
+
history_display.value = history_component.format_history_html()
|
141 |
+
|
142 |
+
clear_history_btn.click(
|
143 |
+
fn=history_component.clear_history,
|
144 |
+
outputs=[history_display],
|
145 |
+
api_name="clear_history"
|
146 |
+
)
|
147 |
+
|
148 |
+
refresh_btn.click(
|
149 |
+
fn=history_component.refresh_history,
|
150 |
+
outputs=[history_display],
|
151 |
+
api_name="refresh_history"
|
152 |
+
)
|
153 |
+
|
154 |
+
return history_component
|
styles.py
ADDED
@@ -0,0 +1,785 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
def get_css_styles():
|
3 |
+
return """
|
4 |
+
.dog-info-card {
|
5 |
+
border: 1px solid #e1e4e8;
|
6 |
+
margin: 40px 0;
|
7 |
+
padding: 0;
|
8 |
+
border-radius: 12px;
|
9 |
+
box-shadow: 0 2px 12px rgba(0,0,0,0.08);
|
10 |
+
overflow: hidden;
|
11 |
+
transition: all 0.3s ease;
|
12 |
+
background: white;
|
13 |
+
}
|
14 |
+
|
15 |
+
.dog-info-card:hover {
|
16 |
+
box-shadow: 0 4px 16px rgba(0,0,0,0.12);
|
17 |
+
}
|
18 |
+
|
19 |
+
.dog-info-header {
|
20 |
+
padding: 24px 28px; /* 增加內距 */
|
21 |
+
margin: 0;
|
22 |
+
font-size: 22px;
|
23 |
+
font-weight: bold;
|
24 |
+
border-bottom: 1px solid #e1e4e8;
|
25 |
+
}
|
26 |
+
|
27 |
+
.breed-info {
|
28 |
+
padding: 28px; /* 增加整體內距 */
|
29 |
+
line-height: 1.6;
|
30 |
+
}
|
31 |
+
|
32 |
+
.section-title {
|
33 |
+
font-size: 1.3em;
|
34 |
+
font-weight: 700;
|
35 |
+
color: #2c3e50;
|
36 |
+
margin: 32px 0 20px 0;
|
37 |
+
padding: 12px 0;
|
38 |
+
border-bottom: 2px solid #e1e4e8;
|
39 |
+
text-transform: uppercase;
|
40 |
+
letter-spacing: 0.5px;
|
41 |
+
display: flex;
|
42 |
+
align-items: center;
|
43 |
+
gap: 8px;
|
44 |
+
position: relative;
|
45 |
+
}
|
46 |
+
|
47 |
+
.icon {
|
48 |
+
font-size: 1.2em;
|
49 |
+
display: inline-flex;
|
50 |
+
align-items: center;
|
51 |
+
justify-content: center;
|
52 |
+
}
|
53 |
+
|
54 |
+
.info-section, .care-section, .family-section {
|
55 |
+
display: flex;
|
56 |
+
flex-wrap: wrap;
|
57 |
+
gap: 16px;
|
58 |
+
margin-bottom: 28px; /* 增加底部間距 */
|
59 |
+
padding: 20px; /* 增加內距 */
|
60 |
+
background: #f8f9fa;
|
61 |
+
border-radius: 12px;
|
62 |
+
border: 1px solid #e1e4e8; /* 添加邊框 */
|
63 |
+
}
|
64 |
+
|
65 |
+
.info-item {
|
66 |
+
background: white; /* 改為白色背景 */
|
67 |
+
padding: 14px 18px; /* 增加內距 */
|
68 |
+
border-radius: 8px;
|
69 |
+
display: flex;
|
70 |
+
align-items: center;
|
71 |
+
gap: 10px;
|
72 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
73 |
+
border: 1px solid #e1e4e8;
|
74 |
+
flex: 1 1 auto;
|
75 |
+
min-width: 200px;
|
76 |
+
}
|
77 |
+
|
78 |
+
.label {
|
79 |
+
color: #666;
|
80 |
+
font-weight: 600;
|
81 |
+
font-size: 1.1rem;
|
82 |
+
}
|
83 |
+
|
84 |
+
.value {
|
85 |
+
color: #2c3e50;
|
86 |
+
font-weight: 500;
|
87 |
+
font-size: 1.1rem;
|
88 |
+
}
|
89 |
+
|
90 |
+
.temperament-section {
|
91 |
+
background: #f8f9fa;
|
92 |
+
padding: 20px; /* 增加內距 */
|
93 |
+
border-radius: 12px;
|
94 |
+
margin-bottom: 28px; /* 增加間距 */
|
95 |
+
color: #444;
|
96 |
+
border: 1px solid #e1e4e8; /* 添加邊框 */
|
97 |
+
}
|
98 |
+
|
99 |
+
.description-section {
|
100 |
+
background: #f8f9fa;
|
101 |
+
padding: 24px; /* 增加內距 */
|
102 |
+
border-radius: 12px;
|
103 |
+
margin: 28px 0; /* 增加上下間距 */
|
104 |
+
line-height: 1.8;
|
105 |
+
color: #444;
|
106 |
+
border: 1px solid #e1e4e8; /* 添加邊框 */
|
107 |
+
fontsize: 1.1rem;
|
108 |
+
}
|
109 |
+
.description-section p {
|
110 |
+
margin: 0;
|
111 |
+
padding: 0;
|
112 |
+
text-align: justify; /* 文字兩端對齊 */
|
113 |
+
word-wrap: break-word; /* 確保長單字會換行 */
|
114 |
+
white-space: pre-line; /* 保留換行但合併空白 */
|
115 |
+
max-width: 100%; /* 確保不會超出容器 */
|
116 |
+
}
|
117 |
+
|
118 |
+
.action-section {
|
119 |
+
margin-top: 24px;
|
120 |
+
text-align: center;
|
121 |
+
}
|
122 |
+
|
123 |
+
.akc-button,
|
124 |
+
.breed-section .akc-link,
|
125 |
+
.breed-option .akc-link {
|
126 |
+
display: inline-flex;
|
127 |
+
align-items: center;
|
128 |
+
padding: 14px 28px;
|
129 |
+
background: linear-gradient(145deg, #00509E, #003F7F);
|
130 |
+
color: white;
|
131 |
+
border-radius: 12px; /* 增加圓角 */
|
132 |
+
text-decoration: none;
|
133 |
+
gap: 12px; /* 增加圖標和文字間距 */
|
134 |
+
transition: all 0.3s ease;
|
135 |
+
font-weight: 600;
|
136 |
+
font-size: 1.1em;
|
137 |
+
box-shadow:
|
138 |
+
0 2px 4px rgba(0,0,0,0.1),
|
139 |
+
inset 0 1px 1px rgba(255,255,255,0.1);
|
140 |
+
border: 1px solid rgba(255,255,255,0.1);
|
141 |
+
}
|
142 |
+
|
143 |
+
.akc-button:hover,
|
144 |
+
.breed-section .akc-link:hover,
|
145 |
+
.breed-option .akc-link:hover {
|
146 |
+
background: linear-gradient(145deg, #003F7F, #00509E);
|
147 |
+
transform: translateY(-2px);
|
148 |
+
color: white;
|
149 |
+
box-shadow:
|
150 |
+
0 6px 12px rgba(0,0,0,0.2),
|
151 |
+
inset 0 1px 1px rgba(255,255,255,0.2);
|
152 |
+
border: 1px solid rgba(255,255,255,0.2);
|
153 |
+
}
|
154 |
+
.icon {
|
155 |
+
font-size: 1.3em;
|
156 |
+
filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2));
|
157 |
+
}
|
158 |
+
|
159 |
+
.warning-message {
|
160 |
+
display: flex;
|
161 |
+
align-items: center;
|
162 |
+
gap: 8px;
|
163 |
+
color: #ff3b30;
|
164 |
+
font-weight: 500;
|
165 |
+
margin: 0;
|
166 |
+
padding: 16px;
|
167 |
+
background: #fff5f5;
|
168 |
+
border-radius: 8px;
|
169 |
+
}
|
170 |
+
|
171 |
+
.model-uncertainty-note {
|
172 |
+
display: flex;
|
173 |
+
align-items: center;
|
174 |
+
gap: 12px;
|
175 |
+
padding: 16px;
|
176 |
+
background-color: #f8f9fa;
|
177 |
+
border-left: 4px solid #6c757d;
|
178 |
+
margin-bottom: 20px;
|
179 |
+
color: #495057;
|
180 |
+
border-radius: 4px;
|
181 |
+
}
|
182 |
+
|
183 |
+
.breeds-list {
|
184 |
+
display: flex;
|
185 |
+
flex-direction: column;
|
186 |
+
gap: 20px;
|
187 |
+
}
|
188 |
+
|
189 |
+
.breed-option {
|
190 |
+
background: white;
|
191 |
+
border: 1px solid #e1e4e8;
|
192 |
+
border-radius: 8px;
|
193 |
+
overflow: hidden;
|
194 |
+
}
|
195 |
+
|
196 |
+
.breed-header {
|
197 |
+
display: flex;
|
198 |
+
align-items: center;
|
199 |
+
padding: 16px;
|
200 |
+
background: #f8f9fa;
|
201 |
+
gap: 12px;
|
202 |
+
border-bottom: 1px solid #e1e4e8;
|
203 |
+
}
|
204 |
+
|
205 |
+
.option-number {
|
206 |
+
font-weight: 600;
|
207 |
+
color: #666;
|
208 |
+
padding: 4px 8px;
|
209 |
+
background: #e1e4e8;
|
210 |
+
border-radius: 4px;
|
211 |
+
}
|
212 |
+
|
213 |
+
.breed-name {
|
214 |
+
font-size: 1.5em;
|
215 |
+
font-weight: bold;
|
216 |
+
color: #2c3e50;
|
217 |
+
flex-grow: 1;
|
218 |
+
}
|
219 |
+
|
220 |
+
.confidence-badge {
|
221 |
+
padding: 4px 12px;
|
222 |
+
border-radius: 20px;
|
223 |
+
font-size: 0.9em;
|
224 |
+
font-weight: 500;
|
225 |
+
}
|
226 |
+
|
227 |
+
.breed-content {
|
228 |
+
padding: 20px;
|
229 |
+
}
|
230 |
+
.breed-content li {
|
231 |
+
margin-bottom: 8px;
|
232 |
+
display: flex;
|
233 |
+
align-items: flex-start; /* 改為頂部對齊 */
|
234 |
+
gap: 8px;
|
235 |
+
flex-wrap: wrap; /* 允許內容換行 */
|
236 |
+
}
|
237 |
+
.breed-content li strong {
|
238 |
+
flex: 0 0 auto; /* 不讓標題縮放 */
|
239 |
+
min-width: 100px; /* 給標題一個固定最小寬度 */
|
240 |
+
}
|
241 |
+
|
242 |
+
ul {
|
243 |
+
padding-left: 0;
|
244 |
+
margin: 0;
|
245 |
+
list-style-type: none;
|
246 |
+
}
|
247 |
+
|
248 |
+
li {
|
249 |
+
margin-bottom: 8px;
|
250 |
+
display: flex;
|
251 |
+
align-items: center;
|
252 |
+
gap: 8px;
|
253 |
+
}
|
254 |
+
.akc-link {
|
255 |
+
color: white;
|
256 |
+
text-decoration: none;
|
257 |
+
font-weight: 600;
|
258 |
+
font-size: 1.1em;
|
259 |
+
transition: all 0.3s ease;
|
260 |
+
}
|
261 |
+
|
262 |
+
.akc-link:hover {
|
263 |
+
text-decoration: underline;
|
264 |
+
color: #D3E3F0;
|
265 |
+
}
|
266 |
+
.tooltip {
|
267 |
+
position: relative;
|
268 |
+
display: inline-flex;
|
269 |
+
align-items: center;
|
270 |
+
gap: 4px;
|
271 |
+
cursor: help;
|
272 |
+
}
|
273 |
+
.tooltip .tooltip-icon {
|
274 |
+
font-size: 14px;
|
275 |
+
color: #666;
|
276 |
+
}
|
277 |
+
.tooltip .tooltip-text {
|
278 |
+
visibility: hidden;
|
279 |
+
width: 250px;
|
280 |
+
background-color: rgba(44, 62, 80, 0.95);
|
281 |
+
color: white;
|
282 |
+
text-align: left;
|
283 |
+
border-radius: 8px;
|
284 |
+
padding: 8px 10px;
|
285 |
+
position: absolute;
|
286 |
+
z-index: 100;
|
287 |
+
bottom: 150%;
|
288 |
+
left: 50%;
|
289 |
+
transform: translateX(-50%);
|
290 |
+
opacity: 0;
|
291 |
+
transition: all 0.3s ease;
|
292 |
+
font-size: 14px;
|
293 |
+
line-height: 1.3;
|
294 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
|
295 |
+
border: 1px solid rgba(255, 255, 255, 0.1)
|
296 |
+
margin-bottom: 10px;
|
297 |
+
}
|
298 |
+
.tooltip.tooltip-left .tooltip-text {
|
299 |
+
left: 0;
|
300 |
+
transform: translateX(0);
|
301 |
+
}
|
302 |
+
.tooltip.tooltip-right .tooltip-text {
|
303 |
+
left: auto;
|
304 |
+
right: 0;
|
305 |
+
transform: translateX(0);
|
306 |
+
}
|
307 |
+
.tooltip-text strong {
|
308 |
+
color: white !important;
|
309 |
+
background-color: transparent !important;
|
310 |
+
display: block; /* 讓標題獨立一行 */
|
311 |
+
margin-bottom: 2px; /* 增加標題下方間距 */
|
312 |
+
padding-bottom: 2px; /* 加入小間距 */
|
313 |
+
border-bottom: 1px solid rgba(255,255,255,0.2);
|
314 |
+
}
|
315 |
+
.tooltip-text {
|
316 |
+
font-size: 13px; /* 稍微縮小字體 */
|
317 |
+
}
|
318 |
+
|
319 |
+
/* 調整列表符號和文字的間距 */
|
320 |
+
.tooltip-text ul {
|
321 |
+
margin: 0;
|
322 |
+
padding-left: 15px; /* 減少列表符號的縮進 */
|
323 |
+
}
|
324 |
+
|
325 |
+
.tooltip-text li {
|
326 |
+
margin-bottom: 1px; /* 減少列表項目間的間距 */
|
327 |
+
}
|
328 |
+
.tooltip-text br {
|
329 |
+
line-height: 1.2; /* 減少行距 */
|
330 |
+
}
|
331 |
+
|
332 |
+
.tooltip .tooltip-text::after {
|
333 |
+
content: "";
|
334 |
+
position: absolute;
|
335 |
+
top: 100%;
|
336 |
+
left: 20%; /* 調整箭頭位置 */
|
337 |
+
margin-left: -5px;
|
338 |
+
border-width: 5px;
|
339 |
+
border-style: solid;
|
340 |
+
border-color: rgba(44, 62, 80, 0.95) transparent transparent transparent;
|
341 |
+
}
|
342 |
+
.tooltip-left .tooltip-text::after {
|
343 |
+
left: 20%;
|
344 |
+
}
|
345 |
+
|
346 |
+
/* 右側箭��� */
|
347 |
+
.tooltip-right .tooltip-text::after {
|
348 |
+
left: 80%;
|
349 |
+
}
|
350 |
+
.tooltip:hover .tooltip-text {
|
351 |
+
visibility: visible;
|
352 |
+
opacity: 1;
|
353 |
+
}
|
354 |
+
.tooltip .tooltip-text::after {
|
355 |
+
content: "";
|
356 |
+
position: absolute;
|
357 |
+
top: 100%;
|
358 |
+
left: 50%;
|
359 |
+
transform: translateX(-50%);
|
360 |
+
border-width: 8px;
|
361 |
+
border-style: solid;
|
362 |
+
border-color: rgba(44, 62, 80, 0.95) transparent transparent transparent;
|
363 |
+
}
|
364 |
+
.uncertainty-mode .tooltip .tooltip-text {
|
365 |
+
position: absolute;
|
366 |
+
left: 100%;
|
367 |
+
bottom: auto;
|
368 |
+
top: 50%;
|
369 |
+
transform: translateY(-50%);
|
370 |
+
margin-left: 10px;
|
371 |
+
z-index: 1000; /* 確保提示框在最上層 */
|
372 |
+
}
|
373 |
+
|
374 |
+
.uncertainty-mode .tooltip .tooltip-text::after {
|
375 |
+
content: "";
|
376 |
+
position: absolute;
|
377 |
+
top: 50%;
|
378 |
+
right: 100%;
|
379 |
+
transform: translateY(-50%);
|
380 |
+
border-width: 5px;
|
381 |
+
border-style: solid;
|
382 |
+
border-color: transparent rgba(44, 62, 80, 0.95) transparent transparent;
|
383 |
+
}
|
384 |
+
.uncertainty-mode .breed-content {
|
385 |
+
font-size: 1.1rem; /* 增加字體大小 */
|
386 |
+
}
|
387 |
+
.description-section,
|
388 |
+
.description-section p,
|
389 |
+
.temperament-section,
|
390 |
+
.temperament-section .value,
|
391 |
+
.info-item,
|
392 |
+
.info-item .value,
|
393 |
+
.breed-content {
|
394 |
+
font-size: 1.1rem !important; /* 使用 !important 確保覆蓋其他樣式 */
|
395 |
+
}
|
396 |
+
|
397 |
+
.recommendation-card {
|
398 |
+
margin-bottom: 40px;
|
399 |
+
}
|
400 |
+
|
401 |
+
.compatibility-scores {
|
402 |
+
background: #f8f9fa;
|
403 |
+
padding: 24px;
|
404 |
+
border-radius: 12px;
|
405 |
+
margin: 20px 0;
|
406 |
+
}
|
407 |
+
|
408 |
+
.score-item {
|
409 |
+
margin: 15px 0;
|
410 |
+
}
|
411 |
+
|
412 |
+
.progress-bar {
|
413 |
+
height: 12px;
|
414 |
+
background-color: #e9ecef;
|
415 |
+
border-radius: 6px;
|
416 |
+
overflow: hidden;
|
417 |
+
margin: 8px 0;
|
418 |
+
}
|
419 |
+
|
420 |
+
.progress {
|
421 |
+
height: 100%;
|
422 |
+
background: linear-gradient(90deg, #34C759, #30B350);
|
423 |
+
border-radius: 6px;
|
424 |
+
transition: width 0.6s ease;
|
425 |
+
}
|
426 |
+
|
427 |
+
.percentage {
|
428 |
+
float: right;
|
429 |
+
color: #34C759;
|
430 |
+
font-weight: 600;
|
431 |
+
}
|
432 |
+
|
433 |
+
.breed-details-section {
|
434 |
+
margin: 30px 0;
|
435 |
+
}
|
436 |
+
|
437 |
+
.subsection-title {
|
438 |
+
font-size: 1.2em;
|
439 |
+
color: #2c3e50;
|
440 |
+
margin-bottom: 20px;
|
441 |
+
display: flex;
|
442 |
+
align-items: center;
|
443 |
+
gap: 8px;
|
444 |
+
}
|
445 |
+
|
446 |
+
.details-grid {
|
447 |
+
display: grid;
|
448 |
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
449 |
+
gap: 20px;
|
450 |
+
background: #f8f9fa;
|
451 |
+
padding: 20px;
|
452 |
+
border-radius: 12px;
|
453 |
+
border: 1px solid #e1e4e8;
|
454 |
+
}
|
455 |
+
|
456 |
+
.detail-item {
|
457 |
+
background: white;
|
458 |
+
padding: 15px;
|
459 |
+
border-radius: 8px;
|
460 |
+
border: 1px solid #e1e4e8;
|
461 |
+
}
|
462 |
+
|
463 |
+
.description-text {
|
464 |
+
line-height: 1.8;
|
465 |
+
color: #444;
|
466 |
+
margin: 0;
|
467 |
+
padding: 24px 30px; /* 調整內部間距,從 20px 改為 24px 30px */
|
468 |
+
background: #f8f9fa;
|
469 |
+
border-radius: 12px;
|
470 |
+
border: 1px solid #e1e4e8;
|
471 |
+
text-align: justify; /* 添加文字對齊 */
|
472 |
+
word-wrap: break-word; /* 確保長文字會換行 */
|
473 |
+
word-spacing: 1px; /* 加入字間距 */
|
474 |
+
}
|
475 |
+
|
476 |
+
/* 工具提示改進 */
|
477 |
+
.tooltip {
|
478 |
+
position: relative;
|
479 |
+
display: inline-flex;
|
480 |
+
align-items: center;
|
481 |
+
gap: 4px;
|
482 |
+
cursor: help;
|
483 |
+
padding: 5px 0;
|
484 |
+
}
|
485 |
+
|
486 |
+
.tooltip .tooltip-text {
|
487 |
+
visibility: hidden;
|
488 |
+
width: 280px;
|
489 |
+
background-color: rgba(44, 62, 80, 0.95);
|
490 |
+
color: white;
|
491 |
+
text-align: left;
|
492 |
+
border-radius: 8px;
|
493 |
+
padding: 12px 15px;
|
494 |
+
position: absolute;
|
495 |
+
z-index: 1000;
|
496 |
+
bottom: calc(100% + 15px);
|
497 |
+
left: 50%;
|
498 |
+
transform: translateX(-50%);
|
499 |
+
opacity: 0;
|
500 |
+
transition: all 0.3s ease;
|
501 |
+
font-size: 14px;
|
502 |
+
line-height: 1.4;
|
503 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
|
504 |
+
white-space: normal;
|
505 |
+
}
|
506 |
+
|
507 |
+
.tooltip:hover .tooltip-text {
|
508 |
+
visibility: visible;
|
509 |
+
opacity: 1;
|
510 |
+
}
|
511 |
+
|
512 |
+
.score-badge {
|
513 |
+
background-color: #34C759;
|
514 |
+
color: white;
|
515 |
+
padding: 6px 12px;
|
516 |
+
border-radius: 20px;
|
517 |
+
font-size: 0.9em;
|
518 |
+
margin-left: 10px;
|
519 |
+
font-weight: 500;
|
520 |
+
box-shadow: 0 2px 4px rgba(52, 199, 89, 0.2);
|
521 |
+
}
|
522 |
+
|
523 |
+
.bonus-score .tooltip-text {
|
524 |
+
width: 250px;
|
525 |
+
line-height: 1.4;
|
526 |
+
padding: 10px;
|
527 |
+
}
|
528 |
+
|
529 |
+
.bonus-score .progress {
|
530 |
+
background: linear-gradient(90deg, #48bb78, #68d391);
|
531 |
+
}
|
532 |
+
|
533 |
+
.health-section {
|
534 |
+
margin: 25px 0;
|
535 |
+
padding: 24px;
|
536 |
+
background-color: #f8f9fb;
|
537 |
+
border-radius: 12px;
|
538 |
+
border: 1px solid #e1e4e8;
|
539 |
+
}
|
540 |
+
|
541 |
+
.health-section .subsection-title {
|
542 |
+
font-size: 1.3em;
|
543 |
+
font-weight: 600;
|
544 |
+
margin-bottom: 20px;
|
545 |
+
display: flex;
|
546 |
+
align-items: center;
|
547 |
+
gap: 8px;
|
548 |
+
color: #2c3e50;
|
549 |
+
}
|
550 |
+
|
551 |
+
.health-info {
|
552 |
+
background-color: white;
|
553 |
+
padding: 24px;
|
554 |
+
border-radius: 8px;
|
555 |
+
margin: 15px 0;
|
556 |
+
border: 1px solid #e1e4e8;
|
557 |
+
}
|
558 |
+
|
559 |
+
.health-details {
|
560 |
+
font-size: 1.1rem;
|
561 |
+
line-height: 1.6;
|
562 |
+
}
|
563 |
+
|
564 |
+
.health-details h4 {
|
565 |
+
color: #2c3e50;
|
566 |
+
font-size: 1.15rem;
|
567 |
+
font-weight: 600;
|
568 |
+
margin: 20px 0 15px 0;
|
569 |
+
}
|
570 |
+
|
571 |
+
.health-details h4:first-child {
|
572 |
+
margin-top: 0;
|
573 |
+
}
|
574 |
+
|
575 |
+
.health-details ul {
|
576 |
+
list-style-type: none;
|
577 |
+
padding-left: 0;
|
578 |
+
margin: 0 0 25px 0;
|
579 |
+
}
|
580 |
+
|
581 |
+
.health-details ul li {
|
582 |
+
margin-bottom: 12px;
|
583 |
+
padding-left: 20px;
|
584 |
+
position: relative;
|
585 |
+
}
|
586 |
+
|
587 |
+
.health-details ul li:before {
|
588 |
+
content: "•";
|
589 |
+
position: absolute;
|
590 |
+
left: 0;
|
591 |
+
color: #2c3e50;
|
592 |
+
}
|
593 |
+
|
594 |
+
.health-disclaimer {
|
595 |
+
margin-top: 20px;
|
596 |
+
padding-top: 20px;
|
597 |
+
border-top: 1px solid #e1e4e8;
|
598 |
+
}
|
599 |
+
|
600 |
+
.health-disclaimer p {
|
601 |
+
margin: 6px 0;
|
602 |
+
padding-left: 20px;
|
603 |
+
position: relative;
|
604 |
+
color: #888; /* 統一設定灰色 */
|
605 |
+
font-size: 0.95rem;
|
606 |
+
line-height: 1.5;
|
607 |
+
font-style: italic;
|
608 |
+
}
|
609 |
+
|
610 |
+
.health-disclaimer p:before {
|
611 |
+
content: "›";
|
612 |
+
position: absolute;
|
613 |
+
left: 0;
|
614 |
+
color: #999;
|
615 |
+
font-style: normal;
|
616 |
+
font-weight: 500;
|
617 |
+
}
|
618 |
+
|
619 |
+
.health-disclaimer p:first-child {
|
620 |
+
font-style: normal; /* 取消斜體 */
|
621 |
+
font-weight: 500; /* 加粗 */
|
622 |
+
color: #666; /* 稍深的灰色 */
|
623 |
+
}
|
624 |
+
|
625 |
+
.health-disclaimer p span,
|
626 |
+
.health-disclaimer p strong,
|
627 |
+
.health-disclaimer p em {
|
628 |
+
color: inherit;
|
629 |
+
}
|
630 |
+
|
631 |
+
.history-container {
|
632 |
+
max-width: 800px;
|
633 |
+
margin: 0 auto;
|
634 |
+
padding: 20px;
|
635 |
+
}
|
636 |
+
|
637 |
+
.history-entry {
|
638 |
+
background-color: #f8f9fa;
|
639 |
+
border-radius: 8px;
|
640 |
+
padding: 15px;
|
641 |
+
margin-bottom: 20px;
|
642 |
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
643 |
+
}
|
644 |
+
|
645 |
+
.history-header {
|
646 |
+
display: flex;
|
647 |
+
justify-content: space-between;
|
648 |
+
align-items: center;
|
649 |
+
margin-bottom: 10px;
|
650 |
+
padding-bottom: 10px;
|
651 |
+
border-bottom: 1px solid #eee;
|
652 |
+
}
|
653 |
+
|
654 |
+
.timestamp {
|
655 |
+
color: #666;
|
656 |
+
font-size: 0.9em;
|
657 |
+
}
|
658 |
+
|
659 |
+
.delete-btn {
|
660 |
+
background: none;
|
661 |
+
border: none;
|
662 |
+
cursor: pointer;
|
663 |
+
font-size: 1.2em;
|
664 |
+
padding: 5px;
|
665 |
+
}
|
666 |
+
|
667 |
+
.delete-btn:hover {
|
668 |
+
color: #dc3545;
|
669 |
+
}
|
670 |
+
|
671 |
+
.search-params ul {
|
672 |
+
list-style: none;
|
673 |
+
padding-left: 20px;
|
674 |
+
}
|
675 |
+
|
676 |
+
.search-params li {
|
677 |
+
margin: 5px 0;
|
678 |
+
color: #555;
|
679 |
+
}
|
680 |
+
|
681 |
+
.top-results ol {
|
682 |
+
padding-left: 25px;
|
683 |
+
}
|
684 |
+
|
685 |
+
.top-results li {
|
686 |
+
margin: 5px 0;
|
687 |
+
color: #333;
|
688 |
+
}
|
689 |
+
|
690 |
+
.breed-item {
|
691 |
+
display: flex;
|
692 |
+
justify-content: space-between;
|
693 |
+
align-items: center;
|
694 |
+
padding: 12px 16px;
|
695 |
+
margin: 8px 0;
|
696 |
+
background-color: white;
|
697 |
+
border-radius: 6px;
|
698 |
+
border: 1px solid #e1e4e8;
|
699 |
+
transition: all 0.2s ease;
|
700 |
+
}
|
701 |
+
|
702 |
+
.breed-item:hover {
|
703 |
+
transform: translateX(5px);
|
704 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
705 |
+
}
|
706 |
+
|
707 |
+
.breed-rank {
|
708 |
+
font-weight: 600;
|
709 |
+
color: #666;
|
710 |
+
margin-right: 12px;
|
711 |
+
min-width: 30px;
|
712 |
+
}
|
713 |
+
|
714 |
+
.breed-name {
|
715 |
+
flex: 1;
|
716 |
+
font-weight: 500;
|
717 |
+
color: #2c3e50;
|
718 |
+
padding: 0 12px;
|
719 |
+
}
|
720 |
+
|
721 |
+
.breed-score {
|
722 |
+
font-weight: 600;
|
723 |
+
color: #34C759;
|
724 |
+
padding: 4px 8px;
|
725 |
+
border-radius: 20px;
|
726 |
+
background-color: rgba(52, 199, 89, 0.1);
|
727 |
+
min-width: 70px;
|
728 |
+
text-align: center;
|
729 |
+
}
|
730 |
+
|
731 |
+
.history-entry {
|
732 |
+
background-color: #f8f9fa;
|
733 |
+
border-radius: 12px;
|
734 |
+
padding: 20px;
|
735 |
+
margin-bottom: 25px;
|
736 |
+
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
737 |
+
border: 1px solid #e1e4e8;
|
738 |
+
}
|
739 |
+
|
740 |
+
.history-header {
|
741 |
+
margin-bottom: 15px;
|
742 |
+
padding-bottom: 12px;
|
743 |
+
border-bottom: 1px solid #e1e4e8;
|
744 |
+
}
|
745 |
+
|
746 |
+
.history-header .timestamp {
|
747 |
+
color: #666;
|
748 |
+
font-size: 0.9em;
|
749 |
+
display: flex;
|
750 |
+
align-items: center;
|
751 |
+
gap: 6px;
|
752 |
+
}
|
753 |
+
|
754 |
+
h4 {
|
755 |
+
color: #2c3e50;
|
756 |
+
font-size: 1.1em;
|
757 |
+
margin: 18px 0 12px 0;
|
758 |
+
padding: 0;
|
759 |
+
}
|
760 |
+
|
761 |
+
.params-list ul {
|
762 |
+
list-style: none;
|
763 |
+
padding-left: 0;
|
764 |
+
margin: 10px 0;
|
765 |
+
}
|
766 |
+
|
767 |
+
.params-list li {
|
768 |
+
margin: 8px 0;
|
769 |
+
color: #4a5568;
|
770 |
+
display: flex;
|
771 |
+
align-items: center;
|
772 |
+
}
|
773 |
+
|
774 |
+
.empty-history {
|
775 |
+
text-align: center;
|
776 |
+
padding: 40px 20px;
|
777 |
+
color: #666;
|
778 |
+
font-size: 1.1em;
|
779 |
+
background-color: #f8f9fa;
|
780 |
+
border-radius: 12px;
|
781 |
+
border: 1px dashed #e1e4e8;
|
782 |
+
margin: 20px 0;
|
783 |
+
}
|
784 |
+
|
785 |
+
"""
|