all is
all probabilism is kenotism
all tritheism is geocentrism
all bonism is panzoism
all agathism is bullionism
all monophysitism is psychism
all monotheletism is annihilationism
all perfectibilism is solipsism
all immaterialism is hylicism
all hedonism is omnism
all pejorism is probabiliorism
all asceticism is absurdism
all laicism is the walrus
rules: run python script over and over until you hit the walrus
[source language=’python’]
class ContextFree(object):
def __init__(self):
self.rules = dict()
self.expansion = list()
# rules are stored in self.rules, a dictionary; the rules themselves are
# lists of expansions (which themselves are lists)
def add_rule(self, rule, expansion):
if rule in self.rules:
self.rules[rule].append(expansion)
else:
self.rules[rule] = [expansion]
def expand(self, start):
from random import choice
# if the starting rule was in our set of rules, then we can expand it
if start in self.rules:
possible_expansions = self.rules[start]
# grab one possible expansion
random_expansion = choice(possible_expansions)
# call this method again with the current element of the expansion
for elem in random_expansion:
self.expand(elem)
else:
# if the rule wasn’t found, then it’s a terminal: simply append the
# string to the expansion
self.expansion.append(start)
# utility method to run the expand method and return the results
def get_expansion(self, axiom):
self.expand(axiom)
return self.expansion