2017-11-21 5 views
-2

Unten ist der Code, den ich verwendet habe, um Wordcloud in die Kolben-App zu importieren, aber es zeigt einen Fehler "Signal funktioniert nur im Haupt-Thread" und auch ich kann Name WordCloud nicht importieren.Wie erstelle ich diese Wordcloud auf Flasche?

@app.route('/Wordcloud') 
def Wordcloud(): 
    user_input = "pogba" 
    vats = [] 
    tweets = api.search(user_input) 
    for tweet in tweets: 
    #   print(tweet.text) 
     vats.append(tweet.text) 
     analysis = TextBlob(tweet.text) 
    #   print(analysis.sentiment) 
    #   print() 
    vat = ' '.join(vats) 
    words = re.split(r'(https:)\S+', vat) 
    for word in words: 
     if word == "https:": 
      words.remove(word) 
    vat1 = ' '.join(words) 
    words2 = re.split(r'(@)\S+', vat1) 
    for word in words2: 
     if word == "@": 
      words2.remove(word) 
    vat2 = ' '.join(words2) 
    words3 = re.split(r'\s(RT)\s', vat2) 
    for word in words3: 
     if word == "RT": 
      words3.remove(word) 
    vat3 = ' '.join(words3) 
    #%matplotlib inline 
    plt.figure(figsize=(20,10)) 
    wordcloud = WordCloud(background_color='white', mode = "RGB", width = 2000, height = 1000).generate(vat3) 
    plt.title("text wordcloud") 
    plt.imshow(wordcloud) 
    plt.axis("off") 
    return(plt.show()) 

Antwort

0

Ihr Funktionsname entspricht dem Namen einer anderen Klasse, die Sie importieren möchten.

ändern def Wordcloud()-def Wordcloud_something()