Skip to main content
added 143 characters in body
Source Link
Wander Nauta
  • 3.1k
  • 1
  • 19
  • 22

Output example

Python 3, 363 341 331 316 308 293 289274 characters

import os,sys,re,collections as C
c=C.Counter()
n=sys.argv[1]
o="graph d{"
for w in re.findall("[A-Za-z0-9]*""\w*",open(n).read()):c[w]+=1
del c['']
for w,x in c.most_common(75)[1:]:o+="%s[fontsize=%s,shape=none];"%(w,x/5)
open(n+'.dot','w').write(o+"}")
os.system("fdp -Tpng %s.dot>%s.png"%(n,n))

Call it like this: python cloud.py file.txt. The script uses Graphviz's fdp force-directed graph generator to generate the image (it will spit out a GraphViz file to file.txt.dot and a PNG image file to file.txt.png). This means you'll need to have Graphviz installed.

The image above is the cloud it makes of Shakespeare's Hamlet - sadlyyou can tell, since it doesn't seem to containcontains "To be or not to be"... There's also some delightful nonsense to be found:

It is, to You and I, the Ham of Not thatO lord have us, what now...

Output example

Python 3, 363 341 331 316 308 293 289 characters

import os,sys,re,collections as C
c=C.Counter()
n=sys.argv[1]
o="graph d{"
for w in re.findall("[A-Za-z0-9]*",open(n).read()):c[w]+=1
del c['']
for w,x in c.most_common(75):o+="%s[fontsize=%s,shape=none];"%(w,x/5)
open(n+'.dot','w').write(o+"}")
os.system("fdp -Tpng %s.dot>%s.png"%(n,n))

Call it like this: python cloud.py file.txt. The script uses Graphviz's fdp force-directed graph generator to generate the image (it will spit out a GraphViz file to file.txt.dot and a PNG image file to file.txt.png). This means you'll need to have Graphviz installed.

The image above is the cloud it makes of Shakespeare's Hamlet - sadly, it doesn't seem to contain "To be or not to be"...

Output example

Python 3, 363 308 293 274 characters

import os,sys,re,collections as C
c=C.Counter()
n=sys.argv[1]
o="graph d{"
for w in re.findall("\w*",open(n).read()):c[w]+=1
for w,x in c.most_common(75)[1:]:o+="%s[fontsize=%s,shape=none];"%(w,x/5)
open(n+'.dot','w').write(o+"}")
os.system("fdp -Tpng %s.dot>%s.png"%(n,n))

Call it like this: python cloud.py file.txt. The script uses Graphviz's fdp force-directed graph generator to generate the image (it will spit out a GraphViz file to file.txt.dot and a PNG image file to file.txt.png). This means you'll need to have Graphviz installed.

The image above is the cloud it makes of Shakespeare's Hamlet - you can tell, since it contains "To be or not to be". There's also some delightful nonsense to be found:

It is, to You and I, the Ham of Not thatO lord have us, what now...

Golf!
Source Link
Wander Nauta
  • 3.1k
  • 1
  • 19
  • 22

Output example

Python 3, 363 341 331 316 308308 293 289 characters

import os,sys,re,collections as C;c=CC
c=C.Counter();
n=sys.argv[1];o=""argv[1]
o="graph d{"
for w in re.findall("[A-Za-z0-9]*",open(n).read()):c[w] += 1c[w]+=1
del c[''];o+=("graph d{")c['']
for w, x in c.most_common(75):o+="%s [fontsize=%so+="%s[fontsize=%s,shape=none];"%(w,x/5)
o+="}";openopen(n+'.dot','w').write(oo+"}");os
os.system("fdp -Tpng -o %s.png %sdot>%s.dot"%png"%(n,n))

Call it like this: python cloud.py file.txt. The script uses Graphviz's fdp force-directed graph generator to generate the image (it will spit out a GraphViz file to file.txt.dot and a PNG image file to file.txt.png). This means you'll need to have Graphviz installed.

The image above is the cloud it makes of Shakespeare's Hamlet - sadly, it doesn't seem to contain "To be or not to be"...

Output example

Python 3, 363 341 331 316 308 characters

import os,sys,re,collections as C;c=C.Counter();
n=sys.argv[1];o=""
for w in re.findall("[A-Za-z0-9]*",open(n).read()):c[w] += 1
del c[''];o+=("graph d{")
for w, x in c.most_common(75):o+="%s [fontsize=%s,shape=none];"%(w,x/5)
o+="}";open(n+'.dot','w').write(o);os.system("fdp -Tpng -o %s.png %s.dot"%(n,n))

Call it like this: python cloud.py file.txt. The script uses Graphviz's fdp force-directed graph generator to generate the image (it will spit out a GraphViz file to file.txt.dot and a PNG image file to file.txt.png). This means you'll need to have Graphviz installed.

The image above is the cloud it makes of Shakespeare's Hamlet - sadly, it doesn't seem to contain "To be or not to be"...

Output example

Python 3, 363 341 331 316 308 293 289 characters

import os,sys,re,collections as C
c=C.Counter()
n=sys.argv[1]
o="graph d{"
for w in re.findall("[A-Za-z0-9]*",open(n).read()):c[w]+=1
del c['']
for w,x in c.most_common(75):o+="%s[fontsize=%s,shape=none];"%(w,x/5)
open(n+'.dot','w').write(o+"}")
os.system("fdp -Tpng %s.dot>%s.png"%(n,n))

Call it like this: python cloud.py file.txt. The script uses Graphviz's fdp force-directed graph generator to generate the image (it will spit out a GraphViz file to file.txt.dot and a PNG image file to file.txt.png). This means you'll need to have Graphviz installed.

The image above is the cloud it makes of Shakespeare's Hamlet - sadly, it doesn't seem to contain "To be or not to be"...

don't lowercase
Source Link
Wander Nauta
  • 3.1k
  • 1
  • 19
  • 22

enter image description hereOutput example

Python 3, 363 341 331331 316 308 characters

import os,sys,itertools as I,re,collections as C;c=C.Counter();
n=sys.argv[1];o=""
for w in re.findall("[A-Za-z0-9]*",open(n).read()):c[w.lower()]c[w] += 1
del c[''];o+=("graph d{")
for w, x in c.most_common(75):o+="%s [fontsize=%s,shape=none];"%(w,x/5)
o+="}";open(n+'.dot','w').write(o);os.system("fdp -Tpng -o %s.png %s.dot"%(n,n))

Call it like this: python cloud.py file.txt. The script uses Graphviz's fdp force-directed graph generator to generate the image (it will spit out a GraphViz file to file.txt.dot and a PNG image file to file.txt.png). This means you'll need to have Graphviz installed.

The image above is the cloud it makes of Shakespeare's Hamlet - sadly, it doesn't seem to contain "To be or not to be"...

enter image description here

Python 3, 363 341 331 characters

import os,sys,itertools as I,re,collections as C;c=C.Counter();
n=sys.argv[1];o=""
for w in re.findall("[A-Za-z0-9]*",open(n).read()):c[w.lower()] += 1
del c[''];o+=("graph d{")
for w, x in c.most_common(75):o+="%s [fontsize=%s,shape=none];"%(w,x/5)
o+="}";open(n+'.dot','w').write(o);os.system("fdp -Tpng -o %s.png %s.dot"%(n,n))

Call it like this: python cloud.py file.txt. The script uses Graphviz's fdp force-directed graph generator to generate the image (it will spit out a GraphViz file to file.txt.dot and a PNG image file to file.txt.png). This means you'll need to have Graphviz installed.

The image above is the cloud it makes of Shakespeare's Hamlet - sadly, it doesn't seem to contain "To be or not to be"...

Output example

Python 3, 363 341 331 316 308 characters

import os,sys,re,collections as C;c=C.Counter();
n=sys.argv[1];o=""
for w in re.findall("[A-Za-z0-9]*",open(n).read()):c[w] += 1
del c[''];o+=("graph d{")
for w, x in c.most_common(75):o+="%s [fontsize=%s,shape=none];"%(w,x/5)
o+="}";open(n+'.dot','w').write(o);os.system("fdp -Tpng -o %s.png %s.dot"%(n,n))

Call it like this: python cloud.py file.txt. The script uses Graphviz's fdp force-directed graph generator to generate the image (it will spit out a GraphViz file to file.txt.dot and a PNG image file to file.txt.png). This means you'll need to have Graphviz installed.

The image above is the cloud it makes of Shakespeare's Hamlet - sadly, it doesn't seem to contain "To be or not to be"...

Source Link
Wander Nauta
  • 3.1k
  • 1
  • 19
  • 22
Loading