boffire commited on
Commit
c0117a0
·
verified ·
1 Parent(s): ffdbf14

Update src/gradio_app.py

Browse files
Files changed (1) hide show
  1. src/gradio_app.py +7 -5
src/gradio_app.py CHANGED
@@ -22,8 +22,7 @@ DATASET_API_TREE_URL = f"https://huggingface.co/api/datasets/{DATASET_REPO}/tree
22
 
23
  # --- Hunspell Dictionary Configuration ---
24
  DICT_DIR = os.path.join(os.path.dirname(__file__), "dicts")
25
- AFF_PATH = os.path.join(DICT_DIR, "kab.aff")
26
- DIC_PATH = os.path.join(DICT_DIR, "kab.dic")
27
 
28
  # Caractères de ponctuation à stripper (définis avec des escapes Unicode pour éviter les problèmes d'encodage)
29
  PUNCTUATION_CHARS = '.,!?;:"\'()[]{}«»—–-'
@@ -34,13 +33,16 @@ def get_hunspell():
34
  """Lazy-load the Hunspell dictionary."""
35
  global _hunspell_dict
36
  if _hunspell_dict is None:
37
- if not os.path.exists(AFF_PATH) or not os.path.exists(DIC_PATH):
 
 
38
  raise FileNotFoundError(
39
  f"Dictionnaire Hunspell kabyle non trouvé.\n"
40
- f"Attendu: {AFF_PATH} et {DIC_PATH}\n"
41
  f"Veuillez uploader les fichiers kab.aff et kab.dic dans le dossier 'dicts/' de votre Space."
42
  )
43
- _hunspell_dict = Dictionary.from_files(AFF_PATH, DIC_PATH)
 
44
  return _hunspell_dict
45
 
46
  def correct_word(word: str) -> str:
 
22
 
23
  # --- Hunspell Dictionary Configuration ---
24
  DICT_DIR = os.path.join(os.path.dirname(__file__), "dicts")
25
+ DICT_BASE_PATH = os.path.join(DICT_DIR, "kab") # spylls attend le chemin de base sans extension
 
26
 
27
  # Caractères de ponctuation à stripper (définis avec des escapes Unicode pour éviter les problèmes d'encodage)
28
  PUNCTUATION_CHARS = '.,!?;:"\'()[]{}«»—–-'
 
33
  """Lazy-load the Hunspell dictionary."""
34
  global _hunspell_dict
35
  if _hunspell_dict is None:
36
+ aff_path = DICT_BASE_PATH + ".aff"
37
+ dic_path = DICT_BASE_PATH + ".dic"
38
+ if not os.path.exists(aff_path) or not os.path.exists(dic_path):
39
  raise FileNotFoundError(
40
  f"Dictionnaire Hunspell kabyle non trouvé.\n"
41
+ f"Attendu: {aff_path} et {dic_path}\n"
42
  f"Veuillez uploader les fichiers kab.aff et kab.dic dans le dossier 'dicts/' de votre Space."
43
  )
44
+ # spylls: from_files() prend un seul argument (chemin de base sans extension)
45
+ _hunspell_dict = Dictionary.from_files(DICT_BASE_PATH)
46
  return _hunspell_dict
47
 
48
  def correct_word(word: str) -> str: