Use only Python's random library to generate html-formatted label clouds for existing Data. The idea is to generate a view of the data for different sizes of different color words depending on how many times the same word Appears.
For example, multiple data in the following format:
1gaming1skateboarding2girl friend3surfing the internet3ted talks4reading4writing5facebook5gaming6gaming6martial Arts7partying7playing sport7travel8driving8socializing with friends9eating9procrastinating9sleeping10winning ...
Can be produced as Follows:
first, the data exists in a dict, the key is the word, the value is the number of occurrences:
Words = "in data: word = line.split (' \ t ') [1] If Word not in words: words[word] = 1 else: wor ds[word] + = 1
You will then make html, set different words to random colors, and set different font sizes by the frequency at which the words appear.
html = "" for w, c in words.items (): color = ' RGB (%s,%s,%s) '% (str (random.randint (0, 255)), str (random.randint (0, 25 5)), str (random.randint (0, 255))) fontsize = int (c * 0.1 +) html + = ' <span style=\ ' font-size: ' + str (fontsiz E) + ' px;color: ' + color + '; float:left;\ ' > ' + w + ' </span> ' # dump it to a filewith open (' result.html ', ' WB ') as F: f.write (bytes (html, ' UTF-8 '))
here, It's done!
Use Python to make simple data visualizations yourself