Spaces:
Sleeping
Sleeping
jefffffff9 Claude Sonnet 4.6 commited on
Commit ·
33c3a5a
1
Parent(s): ced078c
Fix Self-Teaching language detection: parse code from dropdown label
Browse files_harvest_hf_dataset and _harvest_wikipedia received "Fula (ful)" from the
dropdown but looked it up in SUPPORTED_LANGUAGES which has "Fula / Pular —
Guinea (ful)" — no match, silently defaulted to bam. Now extract the code
from the trailing (xxx) parentheses directly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -1270,7 +1270,9 @@ def _harvest_wikipedia(lang_label: str, max_articles: int = 100) -> str:
|
|
| 1270 |
"""Fetch Wikipedia text and append to vocabulary.jsonl."""
|
| 1271 |
if _hf_api is None:
|
| 1272 |
return "⚠️ HF_TOKEN not set."
|
| 1273 |
-
|
|
|
|
|
|
|
| 1274 |
if lang not in ("bam", "ful"):
|
| 1275 |
return "⚠️ Supported for Bambara and Fula only."
|
| 1276 |
max_articles = int(max_articles) # Gradio slider returns float
|
|
@@ -1304,7 +1306,10 @@ def _harvest_hf_dataset(lang_label: str, max_samples: int = 500) -> str:
|
|
| 1304 |
"""
|
| 1305 |
if _hf_api is None:
|
| 1306 |
return "⚠️ HF_TOKEN not set."
|
| 1307 |
-
|
|
|
|
|
|
|
|
|
|
| 1308 |
if lang not in ("bam", "ful"):
|
| 1309 |
return "⚠️ Supported for Bambara and Fula only."
|
| 1310 |
max_samples = int(max_samples) # Gradio slider returns float
|
|
|
|
| 1270 |
"""Fetch Wikipedia text and append to vocabulary.jsonl."""
|
| 1271 |
if _hf_api is None:
|
| 1272 |
return "⚠️ HF_TOKEN not set."
|
| 1273 |
+
import re as _re_tmp
|
| 1274 |
+
_m = _re_tmp.search(r'\((\w+)\)$', lang_label.strip())
|
| 1275 |
+
lang = _m.group(1) if _m else SUPPORTED_LANGUAGES.get(lang_label, "bam")
|
| 1276 |
if lang not in ("bam", "ful"):
|
| 1277 |
return "⚠️ Supported for Bambara and Fula only."
|
| 1278 |
max_articles = int(max_articles) # Gradio slider returns float
|
|
|
|
| 1306 |
"""
|
| 1307 |
if _hf_api is None:
|
| 1308 |
return "⚠️ HF_TOKEN not set."
|
| 1309 |
+
# Dropdown sends "Bambara (bam)" / "Fula (ful)" — extract the code in parens
|
| 1310 |
+
import re as _re_tmp
|
| 1311 |
+
_m = _re_tmp.search(r'\((\w+)\)$', lang_label.strip())
|
| 1312 |
+
lang = _m.group(1) if _m else SUPPORTED_LANGUAGES.get(lang_label, "bam")
|
| 1313 |
if lang not in ("bam", "ful"):
|
| 1314 |
return "⚠️ Supported for Bambara and Fula only."
|
| 1315 |
max_samples = int(max_samples) # Gradio slider returns float
|