add validator
This commit is contained in:
24
modules/NER.py
Normal file
24
modules/NER.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# 1 модуль - Распознавание именованных сущностей (NER)
|
||||
|
||||
import spacy
|
||||
|
||||
class NER:
|
||||
"""
|
||||
Класс для выделения именованных сущностей из текста с помощью библиотеки spaCy.
|
||||
"""
|
||||
def __init__(self):
|
||||
self.nlp = spacy.load('ru_core_news_lg')
|
||||
|
||||
def extract_entities(self, text):
|
||||
"""
|
||||
Выделение именованных сущностей из текста.
|
||||
|
||||
Использование: text (<текст>)
|
||||
|
||||
Возвращает set сущностей без повторения
|
||||
"""
|
||||
doc = self.nlp(text)
|
||||
entities = set()
|
||||
for ent in doc.ents:
|
||||
entities.add(ent.text)
|
||||
return entities
|
||||
Reference in New Issue
Block a user