File size: 9,480 Bytes
ebf1310 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
import json
import random
from typing import List, Dict, Any
class CulturalDatabase:
def __init__(self):
self.cultural_facts = [
{
"country": "Japan",
"fact": "In Japan, it's considered rude to blow your nose in public. People excuse themselves to do it privately.",
"category": "etiquette",
"source": "Japanese Cultural Studies"
},
{
"country": "Japan",
"fact": "Japanese business cards (meishi) are exchanged with both hands and should be received with respect and careful examination.",
"category": "business",
"source": "Japanese Business Etiquette Guide"
},
{
"country": "India",
"fact": "India has 22 official languages and over 1,600 spoken languages, making it one of the most linguistically diverse countries.",
"category": "language",
"source": "Indian Linguistic Survey"
},
{
"country": "India",
"fact": "In Indian culture, touching someone's feet is a sign of respect, especially for elders and teachers.",
"category": "greeting",
"source": "Indian Cultural Traditions"
},
{
"country": "Brazil",
"fact": "Brazilians typically hug and kiss on the cheek when greeting, even in business settings.",
"category": "greeting",
"source": "Brazilian Social Customs"
},
{
"country": "Brazil",
"fact": "In Brazil, the 'OK' hand gesture is considered offensive, similar to giving someone the middle finger.",
"category": "etiquette",
"source": "Brazilian Cultural Guide"
},
{
"country": "Germany",
"fact": "Germans value punctuality so much that being late is considered very disrespectful, even by a few minutes.",
"category": "business",
"source": "German Business Culture"
},
{
"country": "Germany",
"fact": "In Germany, it's customary to maintain eye contact during toasts and say 'Prost' or 'Zum Wohl'.",
"category": "food",
"source": "German Dining Etiquette"
},
{
"country": "China",
"fact": "In Chinese culture, the number 8 is considered extremely lucky because it sounds like the word for 'prosperity'.",
"category": "beliefs",
"source": "Chinese Numerology Studies"
},
{
"country": "China",
"fact": "When receiving a business card in China, accept it with both hands and take a moment to read it carefully.",
"category": "business",
"source": "Chinese Business Etiquette"
},
{
"country": "France",
"fact": "French people typically don't eat meals while walking or standing - dining is seen as a social ritual to be savored.",
"category": "food",
"source": "French Culinary Culture"
},
{
"country": "France",
"fact": "In France, it's polite to greet shopkeepers with 'Bonjour' when entering and 'Au revoir' when leaving.",
"category": "etiquette",
"source": "French Social Customs"
},
{
"country": "South Korea",
"fact": "In Korea, you should use both hands when giving or receiving business cards as a sign of respect.",
"category": "business",
"source": "Korean Business Protocol"
},
{
"country": "South Korea",
"fact": "Korean age calculation includes the time spent in the womb, so Koreans are typically 1-2 years older in 'Korean age'.",
"category": "general",
"source": "Korean Cultural Practices"
},
{
"country": "Mexico",
"fact": "Mexican families often have multiple generations living together, and family loyalty is highly valued.",
"category": "family",
"source": "Mexican Family Structures"
},
{
"country": "Mexico",
"fact": "In Mexico, personal space is smaller than in many Western cultures, and people stand closer during conversations.",
"category": "etiquette",
"source": "Mexican Social Norms"
},
{
"country": "Egypt",
"fact": "In Egypt, showing the sole of your foot to someone is considered offensive, so keep feet flat on the ground when sitting.",
"category": "etiquette",
"source": "Egyptian Cultural Guidelines"
},
{
"country": "Egypt",
"fact": "Egyptian hospitality is legendary - guests are often offered tea or coffee multiple times as a sign of welcome.",
"category": "food",
"source": "Egyptian Hospitality Traditions"
},
{
"country": "Russia",
"fact": "Russians believe that smiling without reason is insincere, so don't be surprised by serious expressions in public.",
"category": "expression",
"source": "Russian Social Behavior"
},
{
"country": "Russia",
"fact": "In Russia, it's traditional to remove shoes when entering someone's home, and slippers are often provided for guests.",
"category": "etiquette",
"source": "Russian Home Customs"
},
{
"country": "Thailand",
"fact": "In Thailand, the head is considered sacred, so never touch someone's head, even children.",
"category": "etiquette",
"source": "Thai Cultural Sensitivities"
},
{
"country": "Thailand",
"fact": "Thai people use the 'wai' greeting - pressing palms together and bowing slightly - as a sign of respect.",
"category": "greeting",
"source": "Thai Greeting Customs"
},
{
"country": "Italy",
"fact": "In Italy, cappuccino is traditionally only drunk in the morning, never after meals.",
"category": "food",
"source": "Italian Coffee Culture"
},
{
"country": "Italy",
"fact": "Italians often speak with their hands, and gestures are an integral part of communication.",
"category": "language",
"source": "Italian Communication Styles"
}
]
def search_facts(self, query: str) -> List[Dict[str, Any]]:
"""
Search for relevant cultural facts based on query
"""
query_lower = query.lower()
relevant_facts = []
# Search by country
for fact in self.cultural_facts:
if fact['country'].lower() in query_lower:
relevant_facts.append(fact)
# Search by category
if not relevant_facts:
for fact in self.cultural_facts:
if fact['category'].lower() in query_lower:
relevant_facts.append(fact)
# Search by keywords in fact content
if not relevant_facts:
keywords = query_lower.split()
for fact in self.cultural_facts:
fact_text = fact['fact'].lower()
if any(keyword in fact_text for keyword in keywords):
relevant_facts.append(fact)
return relevant_facts[:5] # Return top 5 matches
def get_random_fact(self) -> Dict[str, Any]:
"""
Get a random cultural fact
"""
return random.choice(self.cultural_facts)
def get_facts_by_country(self, country: str) -> List[Dict[str, Any]]:
"""
Get all facts for a specific country
"""
return [fact for fact in self.cultural_facts if fact['country'].lower() == country.lower()]
def get_facts_by_category(self, category: str) -> List[Dict[str, Any]]:
"""
Get all facts for a specific category
"""
return [fact for fact in self.cultural_facts if fact['category'].lower() == category.lower()]
def get_all_countries(self) -> List[str]:
"""
Get list of all countries in the database
"""
return list(set(fact['country'] for fact in self.cultural_facts))
def get_all_categories(self) -> List[str]:
"""
Get list of all categories in the database
"""
return list(set(fact['category'] for fact in self.cultural_facts)) |