I created the word cloud through wordcloud, but the final image was generated with repeated keywords:
:
textprint:
how to solve this problem?
I created the word cloud through wordcloud, but the final image was generated with repeated keywords:
:
textprint:
how to solve this problem?
is related to the collocations parameter. The default collocations=True, counts matching words. For example, your text is "I am visiting a customer". When collocations is True, "visiting a customer" will be counted as a word, so there will be repetition.
wcd=WordCloud (font_path='simsun.ttc', collocations=False,width=900,height=400,background_color='white',max_words=100,scale=1.5) .generate (text)
remove the repetition with unique, and in the output
use jieba.analyse to separate word frequencies, and then use generate_from_frequencies (keywords)
examples are as follows:
result=jieba.analyse.textrank(text_from_file_with_apath,topK=300,withWeight=True)
keywords = dict()
for i in result:
keywords[i[0]]=i[1]
wc = WordCloud(stopwords=stopwords, font_path=font, width = 1600, height = 900, margin=10, max_font_size = 360, min_font_size = 36, background_color="black", mask=mask).generate_from_frequencies(keywords)
Previous: Please tell me how to return multiple intersections of two arrays in PHP.
Next: How do I delete data at a specific location in an array in the Models of Mongoose?