Как игнорировать слова в предложениях слово облако Python - PullRequest
1 голос
/ 21 января 2020

Я пытаюсь создать облако слов из столбца и хочу игнорировать несколько слов из столбца. Данные, как показано ниже

       comments
I have a 2019 DVD, Tech package
So I went to dealership today to pick up cds. 
Have 2019 Lariat following and hope you get this going.
Curious to this as well.  
Still working on it guys. 
I have a something
Quote: Originally Posted by sigspec I have a 2019 with all features
Quote: Originally Posted by KR2019 you should have eveerything
Quote: Originally Posted by RockWVU So what all does he need then? 

Мой код такой, как показано ниже

def plot_wordcloud(text, mask=None, max_words=400, max_font_size=120, figure_size=(24.0,16.0), 
                   title = None, title_size=40, image_color=False):
    stopwords = set(STOPWORDS)
    more_stopwords = {'Quote','Originally posted'}
    stopwords = stopwords.union(more_stopwords)
def show_wordcloud(data, title = None):
    wordcloud = WordCloud(
        background_color='white',
        stopwords=stopwords,
        max_words=200,
        max_font_size=40, 
        scale=3,
        random_state=1 # chosen at random by flipping a coin; it was heads
    ).generate(str(data))

    fig = plt.figure(1, figsize=(12, 12))
    plt.axis('off')
    if title: 
        fig.suptitle(title, fontsize=20)
        fig.subplots_adjust(top=2.3)

    plt.imshow(wordcloud)
    plt.show()

show_wordcloud(df['Comments'])

Даже после использования стоп-слов слова все еще появляются в облаке. Как я могу игнорировать эти слова.

...