NarratifAI / src /yoruba_knowledge.py
Consulawtech's picture
Deploy NarratifAI ASR system (Whisper + diarization + Claude AI)
04684e6 verified
Raw History Blame Contribute Delete
5.83 kB
# -*- coding: utf-8 -*-
"""
Curated Yoruba linguistic knowledge extracted from FSI Yoruba Basic Course
and verified against standard Yoruba orthography.
Used to guide Claude diacritics post-processing.
"""
# Common Yoruba male names with correct tone marks
YORUBA_MALE_NAMES = {
"Oládélé", "Olúwa", "Olúwarèmí", "Olúwafúnmi", "Olúwátósìn",
"Olúwaseun", "Olúwáṣeun", "Olúwadámilọ́lá", "Olúwatóbilọ́ba",
"Ọ̀pẹ́yemí", "Tímí", "Tópé", "Adéwálé", "Adéyẹmí",
"Adéọlá", "Adéṣínà", "Báyọ̀", "Bísí", "Bọ́lá", "Bólájí",
"Dápọ̀", "Déjì", "Dúrójáyé", "Fẹ́mi", "Fólárìnmí", "Gbénró",
"Gbóláhàn", "Ìfáyẹmí", "Ìrànlọ́wọ́", "Jáké", "Jídé", "Kádárí",
"Káyòde", "Kẹ́hìndé", "Kúnlé", "Ládélé", "Ládòkè", "Lánrẹ",
"Mọ́jísọ́lá", "Múyìwá", "Òjó", "Òkun", "Ọlá", "Ọlátúnbọ̀sún",
"Ọ̀pẹ́", "Rótìmí", "Sẹ́gun", "Sọ́lá", "Sọ̀lá", "Táíwò", "Tòbí",
"Wálé", "Wálé", "Yèmí", "Yẹmí",
}
# Common Yoruba female names with correct tone marks
YORUBA_FEMALE_NAMES = {
"Adébọ̀lá", "Adéọlá", "Adéyẹmí", "Amínbọ́lá", "Amínà",
"Ayọ̀", "Ayọ̀délé", "Bólá", "Bọ́lá", "Bọ́lájí", "Bùkọ̀lá",
"Dáyọ̀", "Dúródọ́lá", "Fọ́lákẹ́", "Fúnmi", "Fúnmilọ́lá",
"Ifẹ́", "Ifẹ́olúwa", "Ìyábọ̀", "Ìyánlú", "Kẹ́hìndé",
"Ládùnkẹ́", "Mọ̀jíṣola", "Mọ̀lára", "Mọ̀níkẹ́", "Ọmọ́tọ́yẹ̀",
"Ọmọ́tọ́lá", "Ọ̀pẹ́yemí", "Rónkẹ́", "Sẹ́gun", "Shọ́lá",
"Títí", "Títíláyọ̀", "Tóyìn", "Wúrà", "Wúràolá", "Yẹmí",
}
# Common Yoruba vocabulary with correct tone marks
YORUBA_VOCABULARY = {
"bàbá": "father",
"ìyá": "mother",
"ọmọ": "child",
"ọkọ": "husband",
"aya": "wife",
"ọ̀rẹ́": "friend",
"ẹ̀bí": "family",
"ilé": "house",
"ìwé": "book",
"ọjà": "market",
"ọ̀fíìsì": "office",
"ìlú": "town",
"ọ̀na": "road",
"ọkọ̀": "vehicle",
"bàtà": "shoes",
"aṣọ": "cloth",
"ounjẹ": "food",
"omi": "water",
"wá": "to come",
"lọ": "to go",
"jẹun": "to eat",
"mu": "to drink",
"sùn": "to sleep",
"kúrò": "to leave",
"padà": "to return",
"wá": "to look for",
"rí": "to see",
"mọ̀": "to know",
"sọ": "to say",
"gbọ́": "to hear",
"ní": "to have",
"fẹ́": "to want",
"lè": "can",
"yẹ": "to befit",
"dára": "good",
"búburú": "bad",
"tóbi": "big",
"kéré": "small",
"tuntun": "new",
"ìgbà": "time",
"òní": "today",
"ànà": "yesterday",
"ọ̀la": "tomorrow",
"àsìkò": "weather/time",
"òwúrọ̀": "morning",
"ọ̀sán": "afternoon",
"alẹ́": "evening",
"òru": "night",
"báwo": "how",
"tàbí": "or",
"sì": "and/then",
"kí": "that/to",
"tí": "that/which",
"fún": "for",
"pẹ̀lú": "with",
"sínú": "into",
"lórí": "on",
"nísàlẹ̀": "under",
"tìbí": "here",
"níbẹ̀": "there",
"háà": "yes",
"rárá": "no",
"ẹ jọ̀ọ́": "please",
"ọ̀pẹ́": "thanks",
"àbúrò": "younger sibling",
"ẹ̀gbọ́n": "elder sibling",
"bàbá ńlá": "grandfather",
"ìyá ńlá": "grandmother",
}
# Tone rules summary for Claude
YORUBA_TONE_RULES = """
YORUBA TONE RULES:
- Yoruba has three tones: HIGH (´), MID (unmarked), LOW (`)
- Every syllable carries a tone
- Long vowels (double letters like aa, ee) carry two tones: one on each mora
- Tone sandhi: Low tone often becomes FALLING tone after High or Rising tone on the preceding syllable
- Possessive constructions: tone of the possessor often changes (e.g., ìwé mi → ìwé mi with mid-mid)
- Question marker 'ń' often raises the tone of the preceding syllable
- The syllabic nasal 'n' or 'm' always carries a tone
COMMON TONE PATTERNS FOR NAMES:
- Olá: High-Mid (not Ola)
- Olúwa: High-Mid-Mid
- Adé: High-Mid
- Wálé: High-Mid-Mid
- Fẹ́mi: High-Mid-Mid
- Bọ́lá: High-Mid
- Tópé: High-Mid-Mid
- Dápọ̀: High-Mid-Low
- Kẹ́hìndé: High-Low-Mid-Mid
- Ọ̀pẹ́: Low-High
- Ìfáyẹmí: Low-High-Mid-Mid
- Ọmọ́tọ́yẹ̀: Low-High-Mid-Low
OPEN VOWELS (with dot below):
- ẹ = open e (like 'e' in 'bet')
- ọ = open o (like 'o' in 'hot')
- These MUST have the dot below in correct spelling
- ṣ = sh sound (must have dot below or stroke through s)
"""
def build_yoruba_prompt_context() -> str:
"""Build a concise prompt context for Claude diacritics correction."""
names_sample = ", ".join(sorted(YORUBA_MALE_NAMES)[:30])
vocab_sample = ", ".join(f"{y} ({e})" for y, e in list(YORUBA_VOCABULARY.items())[:20])
return f"""You are a Yoruba language expert. Your ONLY job is to add correct tone marks and underdots to Yoruba words in transcribed text.
YORUBA ORTHOGRAPHY:
- Three tones: HIGH (\u00b4), MID (unmarked), LOW (`)
- Open vowels: \u1eb9 (open e), \u1ecd (open o) \u2014 MUST have dot below
- Syllabic nasal: \u0144, \u01f9, n, m \u2014 always carries a tone
- sh sound: \u1e63 (s with dot below)
COMMON YORUBA NAMES (correct spelling):
{names_sample}
COMMON VOCABULARY:
{vocab_sample}
{YORUBA_TONE_RULES}
ABSOLUTE RULES:
1. Only change Yoruba words \u2014 leave English words untouched
2. Add missing tone marks and underdots
3. Do NOT translate \u2014 keep the original meaning
4. Do NOT add or remove words
5. Do NOT add explanations, notes, or markdown
6. If there are no Yoruba words, return the original text EXACTLY as-is
7. Output must be ONLY the corrected text, with nothing before or after"""