Skip to content

Instantly share code, notes, and snippets.

@mattlaschneider
Created November 30, 2014 19:08
Show Gist options
  • Save mattlaschneider/dae36b3baaf554e2eaea to your computer and use it in GitHub Desktop.
Save mattlaschneider/dae36b3baaf554e2eaea to your computer and use it in GitHub Desktop.
Here are the files *we verb*, my 2014 nanogenmo entry. It is, in essence, a novelisation of Canadian poet John Riddell's poem *we*. A PDF of the completed novel can be found here: https://www.dropbox.com/s/g41lcmikexssnte/we-verb.pdf?dl=0
# -*- codeing: utf-8 -*-
from urllib2 import urlopen
from json import load
from random import randint
import codecs
import sys
UTF8Writer = codecs.getwriter('utf8')
sys.stdout = UTF8Writer(sys.stdout)
datadump = ''
words = []
nextstart = ''
text = r"""\documentclass{book}
\usepackage[a5paper]{geometry}
\title{we verb}
\author{Matt Schneider}
\begin{document}
\begin{center}
\pagenumbering{gobble}
\textsc{\Huge we verb}\\[.25cm]
\rule{3cm}{.1pt}
\\[1cm]
\textsc{\Large A Novelisation}\\[5cm]
\textsc{\Large Matt Schneider}\\[5cm]
\textsc{\small First Edition}
\end{center}
\cleardoublepage
\begin{flushright}
\textsc{\Huge we verb}
\cleardoublepage
for john riddell
\end{flushright}
\cleardoublepage
\pagenumbering{arabic}
\setlength{\parindent}{0pt}"""
for i in range(0,601):
test = urlopen('http://en.wiktionary.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:English_verbs&cmtype=page&format=json&cmlimit=50&cmcontinue=' + nextstart)
datadump = load(test)
for each in range(0, len(datadump['query']['categorymembers'])): words.append(datadump['query']['categorymembers'][each])
nextstart = datadump['query-continue']['categorymembers']['cmcontinue']
for each in words:
if each['ns'] == 0: text += 'we ' + each['title']text + ' '
if randint(0,500) == 0: text += '\n'
text += '\end{document}'
print(text)#.encode('ascii','ignore'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment