“Python Удалить Стоп Слова” Ответ

Python Удалить Стоп Слова

from nltk.corpus import stopwords
nltk.download("stopwords")
stop = set(stopwords.words("english"))
filtered_words = [word.lower() for word in text.split() if word.lower() not in stop]
Plif Plouf

Python удалить все, кроме чисел

>>> import re
>>> re.sub('\D', '', 'aas30dsa20')
'3020'
Dead Dingo

Как удалить остановки слов в питоне

# You need a set of stopwords. You can build it by yourself if OR use built-in sets in modules like nltk and spacy

# in nltk
import nltk
nltk.download('stopwords') # needed once
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize 
stop_words = set(stopwords.words('english')) 
example_sent = "This is my awesome sentence"
# tokenization at the word level
word_tokens = word_tokenize(example_sent) 
# list of words not in the stopword list
filtered_sentence = [w for w in word_tokens if not w.lower() in stop_words] 

# in spacy
# from terminal
python -m spacy download en_core_web_lg # or some other pretrained model
# in your program
import spacy
nlp = spacy.load("en_core_web_lg") 
stop_words = nlp.Defaults.stop_words
example_sent = "This is my awesome sentence"
doc = nlp(example_sent) 
filtered_sentence = [w.text for w in doc if not w.text.lower() in stop_words] 
wolf-like_hunter

Ответы похожие на “Python Удалить Стоп Слова”

Вопросы похожие на “Python Удалить Стоп Слова”

Больше похожих ответов на “Python Удалить Стоп Слова” по Python

Смотреть популярные ответы по языку

Смотреть другие языки программирования