def make_cloud(self, text): words = wordcloud.process_text(text) elements = wordcloud.fit_words(words, width = 400, height = 400) wordcloud.draw(elements, self.out, width = 400, height = 400, scale = 2) return self.out
def makeCloud(self, text, font=None): if font is None: font = random.choice(self.fonts) words, counts = wordcloud.process_text(text, max_features=2000) elements = wordcloud.fit_words(words, counts, width=self.size, height=self.size, font_path=font) wordcloud.draw(elements, self.outFile, width=self.size, height=self.size, scale=self.scale, font_path=font)
d = path.dirname(__file__) # String to hold the text from the webpages. text = ""; # Array of webpages which we'll loop through (from googling Deonte Burton draft). url_list = ["http://www.draftexpress.com/profile/Deonte-Burton-6487/", "http://blogs.rgj.com/chrismurray/2014/01/10/nba-scouts-view-nevadas-deonte-burton-as-solid-draft-pick-but-not-a-first-rounder/", "http://www.nbadraftroom.com/2014/01/deonte-burton.html", "http://www.nbadraftinsider.com/deonte-burton/", "http://nbaprospects.blogspot.com/2012/08/scouting-report-deonte-burton-nevada.html", "http://rushthecourt.net/2014/01/09/a-college-basketball-resolution-for-2014-get-to-know-nevadas-deonte-burton/", "http://mrsportsblog.wordpress.com/2014/03/05/trust-me-on-this-dynamic-deonte-burton-of-nevada-will-be-making-a-living-in-the-nba/", "http://www.draftexpress.com/article/NBA-Draft-Prospect-of-the-Week-Deonte-Burton-4392/", "http://www.nevadawolfpack.com/sports/m-baskbl/spec-rel/021214aad.html"] # Loop through url items and get the text from each. for url in url_list: content = urllib2.urlopen(url) text += Document(content).summary() + " " # Separate into a list of word, frequency). words = wordcloud.process_text(text) # Compute the position of the words. elements = wordcloud.fit_words(words) # Draw the positioned words to a PNG file. wordcloud.draw(elements, path.join(d, 'db2.png'))
def getTopWords(self, text): words = wordcloud.process_text(text, self.config['maxWords'], self.stopwords) return words
#!/usr/bin/env python2 from os import path import sys import wordcloud d = path.dirname(__file__) # Read the whole text. text = open(path.join(d, '4chdata/all.dat')).read() # Separate into a list of (word, frequency). words = wordcloud.process_text(text, max_features=1000) # Compute the position of the words. elements = wordcloud.fit_words(words, width=1000, height=1000) # Draw the positioned words to a PNG file. wordcloud.draw(elements, path.join(d, str(sys.argv[1])), width=1000, height=1000, scale=2)
def produceWordCloud(inputText, outputPng): words = wordcloud.process_text(inputText, max_features=400) elements = wordcloud.fit_words(words, width=800, height=500) wordcloud.draw(elements, outputPng, width=800, height=500, scale=2)
def wordclouds(x): d = path.dirname("/Users/MrG/Capstone/") words = wordcloud.process_text(str(x), max_features = 500) elements = wordcloud.fit_words(words) wordcloud.draw(elements, path.join(d,"WC.png"), scale = 5) return Image(filename='/Users/MrG/Capstone/WC.png', height= 1000, width= 618)
def generateCloud(text): dir = path.dirname(__file__) words = wordcloud.process_text(text, max_features=1000) elements = wordcloud.fit_words(words, width=1000, height=1000) wordcloud.draw(elements, path.join(dir, 'wordcloud.png'), width=1000, height=1000)