Skip to content

Instantly share code, notes, and snippets.

@flavioamieiro
Created August 20, 2014 01:10
Show Gist options
  • Save flavioamieiro/4efe0ef0fff213e83883 to your computer and use it in GitHub Desktop.
Save flavioamieiro/4efe0ef0fff213e83883 to your computer and use it in GitHub Desktop.
Get wordcloud from a document in PyPLN
#!/usr/bin/env python2
# just give this script a document id (as in `$ python get_wordcloud.py 1`, for example)
# and it will download the wordcloud from PyPLN.
#
# Replace PYPLN_URL by the desired host.
import base64
import sys
import pypln.api
doc_id = int(sys.argv[1])
PYPLN_URL = 'http://localhost:8000'
doc = pypln.api.Document.from_url("{}/documents/{}/".format(
PYPLN_URL, doc_id), ("admin", "admin"))
with open("wordcloud_{}.png".format(doc_id), 'w') as fd:
fd.write(base64.b64decode(doc.get_property("wordcloud")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment