Spaces:
Runtime error
Runtime error
Update models/space_er.py
Browse files- models/space_er.py +5 -1
models/space_er.py
CHANGED
|
@@ -40,6 +40,10 @@ label_map = {
|
|
| 40 |
def extract_entities(text: str):
|
| 41 |
"""
|
| 42 |
Extract named entities from Arabic text using GLiNER.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
Returns:
|
| 44 |
list[list[str]]: Table of extracted entities [text, arabic_label] or empty list.
|
| 45 |
"""
|
|
@@ -51,8 +55,8 @@ def extract_entities(text: str):
|
|
| 51 |
if not entities:
|
| 52 |
return []
|
| 53 |
|
|
|
|
| 54 |
return [[ent["text"], label_map.get(ent["label"], ent["label"])] for ent in entities]
|
| 55 |
|
| 56 |
except Exception:
|
| 57 |
return [] # β
ΩΨ§ ΩΨ±Ψ¬ΨΉ Ψ±Ψ³Ψ§ΩΨ© ΩΨ΅ΩΨ© Ψ¨Ω ΩΨ±Ψ¬ΨΉ ΩΨ§Ψ¦Ω
Ψ© ΩΨ§ΨΆΩΨ© ΩΩΨ·
|
| 58 |
-
|
|
|
|
| 40 |
def extract_entities(text: str):
|
| 41 |
"""
|
| 42 |
Extract named entities from Arabic text using GLiNER.
|
| 43 |
+
|
| 44 |
+
Args:
|
| 45 |
+
text (str): Input Arabic text.
|
| 46 |
+
|
| 47 |
Returns:
|
| 48 |
list[list[str]]: Table of extracted entities [text, arabic_label] or empty list.
|
| 49 |
"""
|
|
|
|
| 55 |
if not entities:
|
| 56 |
return []
|
| 57 |
|
| 58 |
+
# Return results with Arabic labels
|
| 59 |
return [[ent["text"], label_map.get(ent["label"], ent["label"])] for ent in entities]
|
| 60 |
|
| 61 |
except Exception:
|
| 62 |
return [] # β
ΩΨ§ ΩΨ±Ψ¬ΨΉ Ψ±Ψ³Ψ§ΩΨ© ΩΨ΅ΩΨ© Ψ¨Ω ΩΨ±Ψ¬ΨΉ ΩΨ§Ψ¦Ω
Ψ© ΩΨ§ΨΆΩΨ© ΩΩΨ·
|
|
|