Spaces:
Build error
Build error
Update NamedEntity.py
Browse files- NamedEntity.py +0 -7
NamedEntity.py
CHANGED
|
@@ -32,16 +32,9 @@ class NER:
|
|
| 32 |
The Constructor for the Named Entity Recognition class.
|
| 33 |
:param text_to_analyse: The text in which to find named entities.
|
| 34 |
"""
|
| 35 |
-
if text_to_analyse is None or len(text_to_analyse.strip()) == 0:
|
| 36 |
-
raise ValueError("text_to_analyse must not be empty and must be set to a valid string value")
|
| 37 |
-
|
| 38 |
self.tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER")
|
| 39 |
-
if self.tokenizer is None:
|
| 40 |
-
raise ValueError("Unable to load tokenizer from DSLIM BERT model")
|
| 41 |
|
| 42 |
self.model = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER")
|
| 43 |
-
if self.model is None:
|
| 44 |
-
raise ValueError("Unable to load model from DSLIM BERT model")
|
| 45 |
|
| 46 |
self.nlp = pipeline("ner", model=self.model, tokenizer=self.tokenizer, grouped_entities=True)
|
| 47 |
if self.nlp is None:
|
|
|
|
| 32 |
The Constructor for the Named Entity Recognition class.
|
| 33 |
:param text_to_analyse: The text in which to find named entities.
|
| 34 |
"""
|
|
|
|
|
|
|
|
|
|
| 35 |
self.tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER")
|
|
|
|
|
|
|
| 36 |
|
| 37 |
self.model = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER")
|
|
|
|
|
|
|
| 38 |
|
| 39 |
self.nlp = pipeline("ner", model=self.model, tokenizer=self.tokenizer, grouped_entities=True)
|
| 40 |
if self.nlp is None:
|