This repository has been archived on 2023-06-09. You can view files and clone it, but cannot push or open issues or pull requests.
jarvis-server/jarvis/utils/nlp_utils.py
2021-07-27 17:55:20 +02:00

18 lines
456 B
Python

import spacy
from jarvis.utils import languages_utils
def get_spacy_nlp():
nlp = spacy.load(languages_utils.get_spacy_model())
return nlp
def get_text_without_stopwords(sentence):
stopwords_spacy = get_spacy_nlp().Defaults.stop_words
stop_words = set(stopwords_spacy)
filtered_sentence = [w for w in sentence.lower().split() if w not in stop_words]
filtered_sentence = " ".join(filtered_sentence)
return filtered_sentence