Spaces:
Sleeping
Sleeping
lang
Browse files
app.py
CHANGED
|
@@ -252,42 +252,7 @@ def get_ai_response(text: str, response_language: str = None) -> str:
|
|
| 252 |
logger.error(f"AI request error: {e}")
|
| 253 |
return f"I'm sorry, I couldn't connect to the AI service. You said: '{text}'."
|
| 254 |
|
| 255 |
-
HAUSA_WORDS = [
|
| 256 |
-
"aikin","manoma","gona","noma","shuka","daji","rani","damina","kasa","ruwa",
|
| 257 |
-
"rana","wata","dare","gari","shinkafa","wake","gyada","abinci","shayi","kofi",
|
| 258 |
-
"yaro","yarinya","mutum","mace","yara","mata","maza","babba","karami","kyau",
|
| 259 |
-
"ina","wane","me","yaushe","yaya","dom","saboda","tare","da","kuma","amma"
|
| 260 |
-
]
|
| 261 |
-
|
| 262 |
-
YORUBA_WORDS = [
|
| 263 |
-
"ọkọ","aya","baba","iya","egbon","aburo","omo","ọjọ","ọsẹ","osu",
|
| 264 |
-
"ọdun","owuro","ọsan","alẹ","ile","ita","oja","aso","ounje","ata",
|
| 265 |
-
"nkan","ti","ni","si","lati","ati","pelu","fun","ninu","lori",
|
| 266 |
-
"wọle","jade","lo","wa","je","mu","sọ","ro","kọ","gbo","ri","mọ"
|
| 267 |
-
]
|
| 268 |
-
|
| 269 |
-
IGBO_WORDS = [
|
| 270 |
-
"ugbo","akụkọ","mmiri","ala","ọrụ","ncheta","ọhụrụ","ugwu","nri","ahụhụ",
|
| 271 |
-
"kedu","ka","si","na","bụ","nke","a","na","ọ","bụ","na","n'ime","n'elu","n'okpuru"
|
| 272 |
-
]
|
| 273 |
-
|
| 274 |
-
ENGLISH_WORDS = [
|
| 275 |
-
"farm","farmer","farming","agriculture","crop","crops","plant","plants","seed","seeds",
|
| 276 |
-
"soil","water","rain","sun","weather","harvest","field","fields","tractor","plow",
|
| 277 |
-
"fertilizer","pesticide","organic","yield","grain","wheat","corn","rice","vegetable",
|
| 278 |
-
"fruit","livestock","cattle","cow","sheep","goat","chicken","pig","milk","meat","eggs"
|
| 279 |
-
]
|
| 280 |
-
|
| 281 |
def detect_language(text: str) -> str:
|
| 282 |
-
text_lower = text.lower()
|
| 283 |
-
if any(word in text_lower for word in HAUSA_WORDS):
|
| 284 |
-
return "ha"
|
| 285 |
-
elif any(word in text_lower for word in YORUBA_WORDS):
|
| 286 |
-
return "yo"
|
| 287 |
-
elif any(word in text_lower for word in IGBO_WORDS):
|
| 288 |
-
return "ig"
|
| 289 |
-
elif any(word in text_lower for word in ENGLISH_WORDS):
|
| 290 |
-
return "en"
|
| 291 |
lang = detect(text)
|
| 292 |
if lang.startswith("ha"):
|
| 293 |
return "ha"
|
|
|
|
| 252 |
logger.error(f"AI request error: {e}")
|
| 253 |
return f"I'm sorry, I couldn't connect to the AI service. You said: '{text}'."
|
| 254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
def detect_language(text: str) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
lang = detect(text)
|
| 257 |
if lang.startswith("ha"):
|
| 258 |
return "ha"
|