这是我在word cloud上的第一个项目-请有人帮忙解决这个问题吗?我收到一个错误-类型错误:“module”对象不可调用。以下是完整的代码供您参考。
# necessary library import from wordcloud import wordcloud import matplotlib.pyplot as plt %matplotlib inline import pandas as pd import numpy as np import nltk from nltk.corpus import stopwords from nltk.tokenize import word_tokenize stop_words = set(stopwords.words('english')) #my text data = '''Data science is the field of study that combines domain expertise, programming skills, and knowledge of mathematics and statistics to extract meaningful insights from data. Data science practitioners apply machine learning algorithms to numbers, text, images, video, audio, and more to produce artificial intelligence (AI) systems to perform tasks that ordinarily require human intelligence. In turn, these systems generate insights which analysts and business users can translate into tangible business value.''' #funtion for word tokenize and remove stopwords def data_processing(data): data_tokens = word_tokenize(data) processed_words = [w for w in data_tokens if not w in stop_words] return " ".join(processed_words) #function run data_processed = data_processing(data) #wordcloud visualization plt.figure(figsize=(10,10), facecolor = 'none') wordcloud= wordcloud().generate(data) plt.imshow(wordcloud) plt.axis('off') plt.show()