Spaces:
Sleeping
Sleeping
Update presidio_helpers.py
Browse files- presidio_helpers.py +2 -16
presidio_helpers.py
CHANGED
@@ -24,19 +24,7 @@ def nlp_engine_and_registry(
|
|
24 |
registry = RecognizerRegistry()
|
25 |
|
26 |
try:
|
27 |
-
if model_family.lower() == "
|
28 |
-
import spacy
|
29 |
-
nlp = spacy.load(model_path)
|
30 |
-
registry.load_predefined_recognizers()
|
31 |
-
registry.add_recognizer_from_dict({
|
32 |
-
"name": "spacy_recognizer",
|
33 |
-
"supported_language": "en",
|
34 |
-
"supported_entities": ["PERSON", "LOCATION", "ORGANIZATION", "DATE_TIME", "NRP"],
|
35 |
-
"model": model_path,
|
36 |
-
"package": "spacy",
|
37 |
-
})
|
38 |
-
return nlp, registry
|
39 |
-
elif model_family.lower() == "flair":
|
40 |
from flair.models import SequenceTagger
|
41 |
tagger = SequenceTagger.load(model_path)
|
42 |
registry.load_predefined_recognizers()
|
@@ -79,9 +67,7 @@ def analyzer_engine(
|
|
79 |
@st.cache_data
|
80 |
def get_supported_entities(model_family: str, model_path: str) -> List[str]:
|
81 |
"""Return supported entities for the selected model."""
|
82 |
-
if model_family.lower() == "
|
83 |
-
return ["PERSON", "LOCATION", "ORGANIZATION", "DATE_TIME", "NRP"]
|
84 |
-
elif model_family.lower() == "huggingface":
|
85 |
return ["PERSON", "LOCATION", "ORGANIZATION", "DATE_TIME"]
|
86 |
elif model_family.lower() == "flair":
|
87 |
return ["PERSON", "LOCATION", "ORGANIZATION"]
|
|
|
24 |
registry = RecognizerRegistry()
|
25 |
|
26 |
try:
|
27 |
+
if model_family.lower() == "flair":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
from flair.models import SequenceTagger
|
29 |
tagger = SequenceTagger.load(model_path)
|
30 |
registry.load_predefined_recognizers()
|
|
|
67 |
@st.cache_data
|
68 |
def get_supported_entities(model_family: str, model_path: str) -> List[str]:
|
69 |
"""Return supported entities for the selected model."""
|
70 |
+
if model_family.lower() == "huggingface":
|
|
|
|
|
71 |
return ["PERSON", "LOCATION", "ORGANIZATION", "DATE_TIME"]
|
72 |
elif model_family.lower() == "flair":
|
73 |
return ["PERSON", "LOCATION", "ORGANIZATION"]
|