File size: 5,828 Bytes
04684e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# -*- 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"""