wordcloud2.py 203 B

1234567
  1. import nltk
  2. from wordcloud import WordCloud
  3. text = open('data.txt', 'r', encoding='utf-8').read()
  4. text = ' '.join(nltk.word_tokenize(text))
  5. cloud = WordCloud().generate(text)
  6. cloud.to_file('output.png')