License Python Software Foundation License (Python 2.x)
Lines 224
Keywords
grammar (1) philosophy (1) random (8) thank-you note (1)
Included in this Library
Permissions
Viewable by Everyone
Editable by All Siafoo Users
Hide
Writing an article is easy - try our reStructured Text demo Join Siafoo Now or Learn More

Generate Mock Philosophy with a Context-Free Grammar Atom Feed 0

In Brief Generates random philosophies based on the works of Kant and Husserl, thank you notes, and more using a context-free grammar.... more
# 's
  1#!/usr/bin/env python
2"""Kant Generator for Python
3
4Generates mock philosophy based on a context-free grammar
5
6Usage: python kgp.py [options] [source]
7
8Options:
9 -g ..., --grammar=... use specified grammar file or URL
10 -h, --help show this help
11 -d show debugging information while parsing
12
13Examples:
14 kgp.py generates several paragraphs of Kantian philosophy
15 kgp.py -g husserl.xml generates several paragraphs of Husserl
16 kpg.py "<xref id='paragraph'/>" generates a paragraph of Kant
17 kgp.py template.xml reads from template.xml to decide what to generate
18
19This program is part of "Dive Into Python", a free Python book for
20experienced programmers. Visit http://diveintopython.org/ for the
21latest version.
22"""
23
24__author__ = "Mark Pilgrim (mark@diveintopython.org)"
25__version__ = "$Revision: 1.4 $"
26__date__ = "$Date: 2004/05/05 21:57:19 $"
27__copyright__ = "Copyright (c) 2001 Mark Pilgrim"
28__license__ = "Python"
29
30from xml.dom import minidom
31import random
32import toolbox
33import sys
34import getopt
35
36_debug = 0
37
38class NoSourceError(Exception): pass
39
40class KantGenerator:
41 """generates mock philosophy based on a context-free grammar"""
42
43 def __init__(self, grammar, source=None):
44 self.loadGrammar(grammar)
45 self.loadSource(source and source or self.getDefaultSource())
46 self.refresh()
47
48 def _load(self, source):
49 """load XML input source, return parsed XML document
50
51 - a URL of a remote XML file ("http://diveintopython.org/kant.xml")
52 - a filename of a local XML file ("~/diveintopython/common/py/kant.xml")
53 - standard input ("-")
54 - the actual XML document, as a string
55 """
56 sock = toolbox.openAnything(source)
57 xmldoc = minidom.parse(sock).documentElement
58 sock.close()
59 return xmldoc
60
61 def loadGrammar(self, grammar):
62 """load context-free grammar"""
63 self.grammar = self._load(grammar)
64 self.refs = {}
65 for ref in self.grammar.getElementsByTagName("ref"):
66 self.refs[ref.attributes["id"].value] = ref
67
68 def loadSource(self, source):
69 """load source"""
70 self.source = self._load(source)
71
72 def getDefaultSource(self):
73 """guess default source of the current grammar
74
75 The default source will be one of the <ref>s that is not
76 cross-referenced. This sounds complicated but it's not.
77 Example: The default source for kant.xml is
78 "<xref id='section'/>", because 'section' is the one <ref>
79 that is not <xref>'d anywhere in the grammar.
80 In most grammars, the default source will produce the
81 longest (and most interesting) output.
82 """
83 xrefs = {}
84 for xref in self.grammar.getElementsByTagName("xref"):
85 xrefs[xref.attributes["id"].value] = 1
86 xrefs = xrefs.keys()
87 standaloneXrefs = [e for e in self.refs.keys() if e not in xrefs]
88 if not standaloneXrefs:
89 raise NoSourceError, "can't guess source, and no source specified"
90 return '<xref id="%s"/>' % random.choice(standaloneXrefs)
91
92 def reset(self):
93 """reset parser"""
94 self.pieces = []
95 self.capitalizeNextWord = 0
96
97 def refresh(self):
98 """reset output buffer, re-parse entire source file, and return output
99
100 Since parsing involves a good deal of randomness, this is an
101 easy way to get new output without having to reload a grammar file
102 each time.
103 """
104 self.reset()
105 self.parse(self.source)
106 return self.output()
107
108 def output(self):
109 """output generated text"""
110 return "".join(self.pieces)
111
112 def randomChildElement(self, node):
113 """choose a random child element of a node
114
115 This is a utility method used by do_xref and do_choice.
116 """
117 choices = [e for e in node.childNodes
118 if e.nodeType == e.ELEMENT_NODE]
119 chosen = random.choice(choices)
120 if _debug:
121 sys.stderr.write('%s available choices: %s\n' % \
122 (len(choices), [e.toxml() for e in choices]))
123 sys.stderr.write('Chosen: %s\n' % chosen.toxml())
124 return chosen
125
126 def parse(self, node):
127 """parse a single XML node
128
129 A parsed XML document (from minidom.parse) is a tree of nodes
130 of various types. Each node is represented by an instance of the
131 corresponding Python class (Element for a tag, Text for
132 text data, Document for the top-level document). The following
133 statement constructs the name of a class method based on the type
134 of node we're parsing ("parse_Element" for an Element node,
135 "parse_Text" for a Text node, etc.) and then calls the method.
136 """
137 parseMethod = getattr(self, "parse_%s" % node.__class__.__name__)
138 parseMethod(node)
139
140 def parse_Document(self, node):
141 """parse the document node
142
143 The document node by itself isn't interesting (to us), but
144 its only child, node.documentElement, is: it's the root node
145 of the grammar.
146 """
147 self.parse(node.documentElement)
148
149 def parse_Text(self, node):
150 """parse a text node
151
152 The text of a text node is usually added to the output buffer
153 verbatim. The one exception is that <p class='sentence'> sets
154 a flag to capitalize the first letter of the next word. If
155 that flag is set, we capitalize the text and reset the flag.
156 """
157 text = node.data
158 if self.capitalizeNextWord:
159 self.pieces.append(text[0].upper())
160 self.pieces.append(text[1:])
161 self.capitalizeNextWord = 0
162 else:
163 self.pieces.append(text)
164
165 def parse_Element(self, node):
166 """parse an element
167
168 An XML element corresponds to an actual tag in the source:
169 <xref id='...'>, <p chance='...'>, <choice>, etc.
170 Each element type is handled in its own method. Like we did in
171 parse(), we construct a method name based on the name of the
172 element ("do_xref" for an <xref> tag, etc.) and
173 call the method.
174 """
175 handlerMethod = getattr(self, "do_%s" % node.tagName)
176 handlerMethod(node)
177
178 def parse_Comment(self, node):
179 """parse a comment
180
181 The grammar can contain XML comments, but we ignore them
182 """
183 pass
184
185 def do_xref(self, node):
186 """handle <xref id='...'> tag
187
188 An <xref id='...'> tag is a cross-reference to a <ref id='...'>
189 tag. <xref id='sentence'/> evaluates to a randomly chosen child of
190 <ref id='sentence'>.
191 """
192 id = node.attributes["id"].value
193 self.parse(self.randomChildElement(self.refs[id]))
194
195 def do_p(self, node):
196 """handle <p> tag
197
198 The <p> tag is the core of the grammar. It can contain almost
199 anything: freeform text, <choice> tags, <xref> tags, even other
200 <p> tags. If a "class='sentence'" attribute is found, a flag
201 is set and the next word will be capitalized. If a "chance='X'"
202 attribute is found, there is an X% chance that the tag will be
203 evaluated (and therefore a (100-X)% chance that it will be
204 completely ignored)
205 """
206 keys = node.attributes.keys()
207 if "class" in keys:
208 if node.attributes["class"].value == "sentence":
209 self.capitalizeNextWord = 1
210 if "chance" in keys:
211 chance = int(node.attributes["chance"].value)
212 doit = (chance > random.randrange(100))
213 else:
214 doit = 1
215 if doit:
216 for child in node.childNodes: self.parse(child)
217
218 def do_choice(self, node):
219 """handle <choice> tag
220
221 A <choice> tag contains one or more <p> tags. One <p> tag
222 is chosen at random and evaluated; the rest are ignored.
223 """
224 self.parse(self.randomChildElement(node))
225
226def usage():
227 print __doc__
228
229def main(argv):
230 grammar = "kant.xml"
231 try:
232 opts, args = getopt.getopt(argv, "hg:d", ["help", "grammar="])
233 except getopt.GetoptError:
234 usage()
235 sys.exit(2)
236 for opt, arg in opts:
237 if opt in ("-h", "--help"):
238 usage()
239 sys.exit()
240 elif opt == '-d':
241 global _debug
242 _debug = 1
243 elif opt in ("-g", "--grammar"):
244 grammar = arg
245
246 source = "".join(args)
247 k = KantGenerator(grammar, source)
248 print k.output()
249
250if __name__ == "__main__":
251 main(sys.argv[1:])

Generates random philosophies based on the works of Kant and Husserl, thank you notes, and more using a context-free grammar.

Use it like python kgp.py -g grammar.xml, where grammar.xml is one of the files below.

For this to work, you'll need the snippet Open Any Input Source as a File-like Object imported as openanything and the xml-formatted grammars below.

1   kant.xml

Generates mock philosophy based on the works of Immanuel Kant.

1.1   Example

By means of analysis, our a priori judgements, in view of these considerations, constitute the whole content of philosophy. Natural causes can not take account of, insomuch as our experience relies on the Antinomies, our sense perceptions. By means of analytic unity, the objects in space and time, certainly, would be falsified. By virtue of practical reason, the reader should be careful to observe that our ideas are a representation of space; still, the Categories have lying before them the Categories.

1.2   Code

# 's
  1<?xml version="1.0"?>
2<!DOCTYPE grammar PUBLIC "-//diveintopython.org//DTD Kant Generator Pro v1.0//EN" "kgp.dtd">
3<grammar>
4<ref id="conjunction">
5 <p>and</p>
6 <p>but</p>
7 <p>yet</p>
8</ref>
9
10<ref id="quantity">
11 <p>all of</p>
12 <p>some of</p>
13 <p>none of</p>
14</ref>
15
16<ref id="logic.type">
17 <p>general</p>
18 <p>applied</p>
19 <p>pure</p>
20 <p>transcendental</p>
21 <p>formal</p>
22</ref>
23
24<ref id="rule.type">
25 <p>universal</p>
26 <p>necessary</p>
27 <p>practical</p>
28 <p>contradictory</p>
29 <p>sufficient</p>
30</ref>
31
32<ref id="judgement.type">
33 <p>hypothetical</p>
34 <p>problematic</p>
35 <p>analytic</p>
36 <p>synthetic</p>
37 <p>ampliative</p>
38 <p>inductive</p>
39 <p>speculative</p>
40 <p>disjunctive</p>
41 <p><xref id="knowledge.type"/></p>
42</ref>
43
44<ref id="knowledge.type">
45 <p>a priori</p>
46 <p>a posteriori</p>
47</ref>
48
49<ref id="reason.type">
50 <p>pure</p>
51 <p>practical</p>
52 <p>human</p>
53 <p>natural</p>
54</ref>
55
56<ref id="object.type">
57 <p>intelligible</p>
58 <p>transcendental</p>
59 <p>empirical</p>
60</ref>
61
62<ref id="philosopher">
63 <p>Aristotle</p>
64 <p>Hume</p>
65 <p>Galileo</p>
66</ref>
67
68<ref id="Ns">
69 <p>the transcendental aesthetic</p>
70 <p><xref id="logic.type"/> logic</p>
71 <p>the Ideal of <xref id="reason.type"/> reason</p>
72 <p>the architectonic of <xref id="reason.type"/> reason</p>
73 <p>the discipline of <xref id="reason.type"/> reason</p>
74 <p>the <p chance="50"><choice><p>pure</p><p>practical</p></choice> </p>employment of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
75 <p>the Ideal</p>
76 <p>the manifold</p>
77 <p>the Transcendental Deduction</p>
78 <p>our experience</p>
79 <p>philosophy</p>
80 <p>metaphysics</p>
81 <p>the thing in itself</p>
82 <p>our understanding</p>
83 <p>our <p chance="50"><xref id="knowledge.type"/> </p>knowledge</p>
84 <p><xref id="reason.type"/> reason</p>
85 <p>space</p>
86 <p>time</p>
87 <p>the transcendental unity of apperception</p>
88 <p>necessity</p>
89 <p>the never-ending regress in the series of empirical conditions</p>
90</ref>
91
92<ref id="Np">
93 <p>the Antinomies</p>
94 <p>the paralogisms<p chance="50"> of <xref id="reason.type"/> reason</p></p>
95 <p>the Categories</p>
96 <p>our sense perceptions</p>
97 <p>our faculties</p>
98 <p>our <p chance="50"><xref id="judgement.type"/> </p>judgements</p>
99 <p>the objects in space and time</p>
100 <p>the things in themselves</p>
101 <p>natural causes</p>
102 <p>our ideas</p>
103 <p>our <p chance="50"><xref id="knowledge.type"/> </p>concepts</p>
104 <p>the <p chance="50"><xref id="object.type"/> </p>objects in space and time</p>
105 <p>the noumena</p>
106 <p>the phenomena</p>
107</ref>
108
109<ref id="Vst">
110 <p>is what first gives rise to</p>
111 <p>can thereby determine in its totality</p>
112 <p>has lying before it</p>
113 <p>constitutes the whole content for</p>
114 <p>may not contradict itself, but it is still possible that it may be in contradictions with</p>
115 <p>would thereby be made to contradict</p>
116 <p>teaches us nothing whatsoever regarding the content of</p>
117 <p>can not take account of</p>
118 <p>has nothing to do with</p>
119 <p>stands in need of</p>
120 <p>is the key to understanding</p>
121 <p>proves the validity of</p>
122 <p>is just as necessary as</p>
123 <p>is the clue to the discovery of</p>
124 <p>is a representation of</p>
125 <p>depends on</p>
126 <p>excludes the possibility of</p>
127</ref>
128
129<ref id="Vsi">
130 <p>is the mere result of the power of <xref id="Ns"/>, a blind but indispensable function of the soul</p>
131 <p>occupies part of the sphere of <xref id="Ns"/> concerning the existence of <xref id="Np"/> in general</p>
132 <p>is by its very nature contradictory</p>
133 <p>would be falsified</p>
134 <p>abstracts from all content of <p chance="50"><xref id="knowledge.type"/> </p>knowledge</p>
135 <p>is a body of demonstrated science, and <xref id="quantity"/> it must be known <xref id="knowledge.type"/></p>
136 <p>can never furnish a true and demonstrated science, because, like <xref id="Ns"/>, it <xref id="Vst"/> <xref id="judgement.type"/> principles</p>
137 <p>can be treated like <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
138 <p>exists in <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
139</ref>
140
141<ref id="Vpt">
142 <p>are what first give rise to</p>
143 <p>have lying before them</p>
144 <p>constitute the whole content of</p>
145 <p>would thereby be made to contradict</p>
146 <p>can not take account of</p>
147 <p>have nothing to do with</p>
148 <p>stand in need to</p>
149 <p>are the clue to the discovery of</p>
150 <p>prove the validity of</p>
151 <p>are just as necessary as</p>
152 <p>are a representation of</p>
153 <p>exclude the possibility of</p>
154</ref>
155
156<ref id="Vpi">
157 <p>are the mere results of the power of <xref id="Ns"/>, a blind but indispensable function of the soul</p>
158 <p>occupy part of the sphere of <xref id="Ns"/> concerning the existence of <xref id="Np"/> in general</p>
159 <p>are by their very nature contradictory</p>
160 <p>would be falsified</p>
161 <p>abstract from all content of <p chance="50"><xref id="knowledge.type"/> </p>knowledge</p>
162 <p>constitute a body of demonstrated doctrine, and <xref id="quantity"/> this body must be known <xref id="knowledge.type"/></p>
163 <p>can never, as a whole, furnish a true and demonstrated science, because, like <xref id="Ns"/>, they <xref id="Vpt"/> <xref id="judgement.type"/> principles</p>
164 <p>can be treated like <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
165 <p>should only be used as a canon for <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
166 <p>exist in <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
167</ref>
168
169<ref id="intro.clause">
170 <p>in all theoretical sciences</p>
171 <p>in view of these considerations</p>
172 <p>thus</p>
173 <p>by means of <xref id="Ns"/></p>
174 <p>in the study of <xref id="Ns"/></p>
175 <p>therefore</p>
176 <p>with the sole exception of <xref id="Ns"/></p>
177 <p>certainly</p>
178 <p>still</p>
179 <p>as I have elsewhere shown</p>
180 <p>on the other hand</p>
181 <p>for these reasons</p>
182 <p>in the case of <xref id="Ns"/></p>
183 <p>however</p>
184 <p>in natural theology</p>
185 <p>consequently</p>
186</ref>
187
188<ref id="certainty.clause">
189 <p>it must not be supposed that</p>
190 <p>there can be no doubt that</p>
191 <p>we can deduce that</p>
192 <p>it is not at all certain that</p>
193 <p><xref id="philosopher"/> tells us that</p>
194 <p>it remains a mystery why</p>
195 <p>I assert<p chance="50">, <xref id="intro.clause"/>,</p> that</p>
196 <p>to avoid all misapprehension, it is necessary to explain that</p>
197 <p>let us suppose that</p>
198 <p>it is obvious that</p>
199 <p>the reader should be careful to observe that</p>
200 <p>what we have alone been able to show is that</p>
201</ref>
202
203<ref id="proof">
204 <p>because of our necessary ignorance of the conditions</p>
205 <p>as is shown in the writings of <xref id="philosopher"/></p>
206 <p>as is proven in the ontological manuals</p>
207 <p>as any dedicated reader can clearly see</p>
208 <p>as is evident upon close examination</p>
209 <p>as will easily be shown in the next section</p>
210 <p>since knowledge of <xref id="Np"/> is <xref id="knowledge.type"/></p>
211 <p>by virtue of <xref id="reason.type"/> reason</p>
212 <p>as we have already seen</p>
213 <p>since <xref id="quantity"/> <xref id="Np"/> are <xref id="judgement.type"/></p>
214 <p>because of the relation between <xref id="Ns"/> and <xref id="Np"/></p>
215 <p>by means of analysis</p>
216 <p>by means of analytic unity</p>
217</ref>
218
219<ref id="throwaway.clause">
220 <p>in so far as this expounds the <xref id="rule.type"/> rules of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
221 <p>when thus treated as <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
222 <p>in other words</p>
223 <p>in the full sense of these terms</p>
224 <p>insomuch as <xref id="Ns"/> relies on <xref id="Np"/></p>
225 <p>indeed</p>
226 <p>then</p>
227 <p>that is to say</p>
228 <p>even as this relates to <xref id="Ns"/></p>
229 <p>in respect of the intelligible character</p>
230 <p>so regarded</p>
231 <p>for example</p>
232 <p>irrespective of all empirical conditions</p>
233 <p>so far as regards <xref id="Ns"/><p chance="50"> and <xref id="Np"/></p></p>
234 <p>on the contrary</p>
235 <p>in accordance with the principles of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
236 <p>in reference to ends</p>
237 <p>in particular</p>
238 <p>so far as I know</p>
239</ref>
240
241<ref id="main.clause">
242 <p><xref id="Ns"/><p chance="50"><choice><p> (and <xref id="certainty.clause"/> this is true)</p><p>, <xref id="throwaway.clause"/>,</p></choice></p> <xref id="Vst"/> <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
243 <p><xref id="Ns"/> <xref id="Vst"/><p chance="50">, <choice><p><xref id="throwaway.clause"/></p><p><xref id="intro.clause"/></p></choice>,</p> <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
244 <p><xref id="Ns"/><p chance="50">, <choice><p><xref id="throwaway.clause"/></p><p><xref id="intro.clause"/></p></choice>,</p> <xref id="Vsi"/></p>
245 <p><xref id="Np"/><p chance="50"><choice><p> (and <xref id="certainty.clause"/> this is the case)</p><p>, <xref id="intro.clause"/>,</p></choice></p> <xref id="Vpt"/> <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
246 <p><xref id="Np"/> <xref id="Vpt"/><p chance="50">, <choice><p><xref id="throwaway.clause"/></p><p><xref id="intro.clause"/></p></choice>,</p> <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
247 <p><xref id="Np"/><p chance="50">, <choice><p><xref id="throwaway.clause"/></p><p><xref id="intro.clause"/></p></choice>,</p> <xref id="Vpi"/></p>
248</ref>
249
250<ref id="sentence">
251 <p class="sentence"><p chance="50"><xref id="intro.clause"/>, </p><p chance="50"><xref id="certainty.clause"/> </p><xref id="main.clause"/><p chance="50">, <xref id="proof"/></p>.</p>
252 <p class="sentence"><p chance="50"><xref id="proof"/>, </p><p chance="50"><xref id="certainty.clause"/>, <xref id="throwaway.clause"/>, </p><xref id="main.clause"/><p chance="50">, <xref id="conjunction"/> <xref id="main.clause"/></p>.</p>
253 <p class="sentence"><p chance="50"><xref id="proof"/>, </p><p chance="50"><xref id="certainty.clause"/> </p><xref id="main.clause"/><p chance="50">; <xref id="intro.clause"/>, <xref id="main.clause"/></p>.</p>
254</ref>
255
256<ref id="question">
257 <p>Whence comes <xref id="Ns"/>, the solution of which involves the relation between <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice> and <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice>?</p>
258<p class="sentence"><p chance="50"><xref id="intro.clause"/>, </p>is it <choice><p>true</p><p>the case</p></choice> that <xref id="Ns"/> <xref id="Vst"/> <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice>, or is the real question whether <xref id="Np"/> <xref id="Vpi"/>?</p>
259 <p>Has it ever been suggested that<p chance="50">, <xref id="proof"/>,</p> <xref id="certainty.clause"/> there is <choice><p>no relation</p><p>a causal connection</p></choice> bewteen <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice> and <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice>?</p>
260 <p>In which of our cognitive faculties are <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice> and <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice> connected together?</p>
261<p class="sentence"><xref id="conjunction"/> can I entertain <xref id="Ns"/> in thought, or does it present itself to me?</p>
262</ref>
263
264<ref id="throwaway.sentence">
265 <p>But we have fallen short of the necessary interconnection that we have in mind when we speak of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice>.</p>
266 <p>We thus have a pure synthesis of apprehension.</p>
267 <p>And similarly with all the others.</p>
268 <p>The question of this matter's relation to objects is not in any way under discussion.</p>
269 <p>This distinction must have some ground in the nature of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice>.</p>
270 <p>The divisions are thus provided; all that is required is to fill them.</p>
271 <p>This could not be passed over in a complete system of transcendental philosophy, but in a merely critical essay the simple mention of the fact may suffice.</p>
272 <p>This is not something we are in a position to establish.</p>
273 <p>This is the sense in which it is to be understood in this work.</p>
274 <p>But this need not worry us.</p>
275 <p>Let us apply this to <xref id="Ns"/>.</p>
276 <p>But to this matter no answer is possible.</p>
277 <p>But the proof of this is a task from which we can here be absolved.</p>
278 <p>But at present we shall turn our attention to <xref id="Ns"/>.</p>
279 <p>This may be clear with an example.</p>
280 <p>I feel I have sufficiently shown this to be true.</p>
281 <p>This is what chiefly concerns us.</p>
282 <p>On this matter, what has been said already should in any case suffice by itself.</p>
283 <p>In my present remarks I am referring to <xref id="Ns"/> only in so far as it is founded on <xref id="judgement.type"/> principles.</p>
284 <p>But this is to be dismissed as random groping.</p>
285</ref>
286
287<ref id="paragraph">
288 <p> <xref id="sentence"/> <xref id="sentence"/> <p chance="50"><xref id="sentence"/> </p><xref id="sentence"/> <p chance="50"><xref id="sentence"/> </p><p chance="50"><xref id="question"/> </p><p chance="50"><xref id="sentence"/> </p><p chance="50"><xref id="sentence"/> </p><xref id="sentence"/> <p chance="50"><xref id="throwaway.sentence"/></p></p>
289 <p> <xref id="sentence"/> <xref id="sentence"/> <p chance="50"><xref id="sentence"/> </p><xref id="sentence"/> <p chance="50">(<xref id="sentence"/>) </p><xref id="sentence"/> <xref id="sentence"/> <p chance="50"><xref id="throwaway.sentence"/></p></p>
290 <p> <xref id="sentence"/> <xref id="sentence"/> <p chance="50"><xref id="sentence"/> </p><xref id="sentence"/> <p chance="50"><xref id="sentence"/> </p><p chance="50"><xref id="sentence"/> </p><p chance="50"><xref id="sentence"/> </p><xref id="sentence"/></p>
291</ref>
292
293<ref id="section">
294 <p><xref id="paragraph"/>
295<xref id="paragraph"/>
296<xref id="paragraph"/>
297<xref id="paragraph"/>
298<p chance="50"><xref id="paragraph"/>
299</p><p chance="50"><xref id="paragraph"/>
300</p><p chance="50"><xref id="paragraph"/>
301</p><p chance="50"><xref id="paragraph"/>
302</p><p chance="50"><xref id="paragraph"/>
303</p><p chance="50"><xref id="paragraph"/>
304</p></p>
305</ref>
306</grammar>

2   husserl.xml

Generates mock philosophies based on the works of Edmond Husserl

2.1   Example

The fact is that the phenomenon, even with respect to the evidence in which experiences present themselves, denotes a universal primal phenomenon of cogitationes. Noetic acts synthetically constitute all particular instances of an object that ever become prominent, by the fundamental nature of an infinite horizon of approximations; we now shift the weight of transcendental evidence of the cogitatum from the ego to multiplicities of an infinite horizon of approximations.

2.2   Code

# 's
  1<?xml version="1.0"?>
2<!DOCTYPE grammar PUBLIC "-//diveintopython.org//DTD Kant Generator Pro v1.0//EN" "kgp.dtd">
3<grammar>
4<ref id="Ns">
5 <p>the phenomenon</p>
6 <p>an object</p>
7 <p>the cogitatum<p chance="50"> (qua cogitatum)</p></p>
8 <p><p chance="50">transcendental </p>phenomenology</p>
9 <p><choice><p>pure<p chance="50"> and genuine</p></p><p>scientific</p></choice> evidence</p>
10 <p>cognition</p>
11 <p>the ego cogito</p>
12 <p>transcendental subjectivity</p>
13 <p>the transcendental-phenomenological reduction</p>
14 <p>the <p chance="50">phenomenological </p>epoche</p>
15 <p>the Objective world</p>
16 <p>a transcendental grounding of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
17 <p>philosophy</p>
18 <p>the stream of <xref id="Np"/></p>
19 <p>what is itself given</p>
20 <p>the repeatable act of grounding<p chance="50"> of <xref id="Np"/></p></p>
21 <p>an infinite horizon of approximations</p>
22 <p>the <xref id="ego.type"/> Ego</p>
23 <p>the fundamental form of this universal synthesis</p>
24 <p>the <p chance="50">all-embracing </p>consciousness of internal time</p>
25 <p>immanent time</p>
26 <p>the task of clarifying <xref id="Np"/></p>
27 <p>the whole of conscious life</p>
28</ref>
29
30<ref id="Np">
31 <p>noetic acts</p>
32 <p>cogitationes</p>
33 <p>noematic descriptions</p>
34 <p><p chance="50">separated </p>modes of consciousness</p>
35 <p>multiplicities of <xref id="Ns"/></p>
36 <p>experiences</p>
37</ref>
38
39<ref id="Vst">
40 <p>denotes a universal primal phenomenon of</p>
41 <p>is only a modality of</p>
42 <p>becomes modalized also in correlation with</p>
43 <p>stands in contrast to the accidental being "for me" of</p>
44 <p>is a clarification of the striving for</p>
45 <p>becomes adjusted to</p>
46</ref>
47
48<ref id="Vpt">
49 <p>exist for us thanks to</p>
50 <p>denote the universal primary phenomena of</p>
51 <p>are only modalities of</p>
52 <p>become modalized also in correlation with</p>
53 <p>stand in contrast to<p chance="50"> the accident being "for me" of</p></p>
54 <p>become adjusted to</p>
55</ref>
56
57<ref id="Vsi">
58 <p>inhibits acceptance of <xref id="Ns"/> as existent</p>
59 <p>is actual</p>
60 <p>does not yet produce for us any abiding being</p>
61 <p>is "in itself"</p>
62 <p>is an infinite idea, related to infinities of harmoniously combinable <xref id="Np"/></p>
63 <p>is an agreement of <xref id="Ns"/> with the judged <xref id="Np"/></p>
64 <p>can be seen as full proof that, in spite of the continual experiencedness of <xref id="Np"/>, a non-being of <xref id="Ns"/> is conceivable</p>
65 <p>needs to be criticized with regard to its validity and range, before it can be used for the purposes of a radical grounding of <xref id="Ns"/></p>
66 <p>is precisely what makes critical decisions about <xref id="Np"/> at all possible</p>
67 <p>is unified synthetically</p>
68 <p>synthetically constitutes all particular <xref id="Np"/> that ever become prominent</p>
69</ref>
70
71<ref id="Vpi">
72 <p>inhibit <p chance="50"><choice><p>my</p><p>our</p></choice> </p>acceptance of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice> as existent</p>
73 <p>do not yet produce for <choice><p>us</p><p>me</p></choice> any abiding being<p chance="50"> apart from their relation to <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p></p>
74 <p>are "in themselves"</p>
75 <p>are infinite ideas, related to infinities of harmoniously combinable <xref id="Np"/><p chance="50"> and <xref id="Np"/></p></p>
76 <p>can be seen as <p chance="50">full </p>proof that, in spite of the continual experiencedness of <xref id="Ns"/>, a non-being of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice> is <choice><p>conceivable</p><p>possible</p></choice></p>
77 <p>need to be criticized with regard to their validity and range, before they can be used for <p chance="50">the purposes of </p>a radical grounding of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
78 <p>are precisely what make critical decisions about <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice> at all possible</p>
79 <p>are unified synthetically</p>
80 <p>synthetically constitute all particular instances of <xref id="Ns"/> that ever become prominent</p>
81</ref>
82
83<ref id="intro.clause">
84 <p>in the natural attitude</p>
85 <p>de facto</p>
86 <p>owing to the instability and ambiguity of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
87 <p>by immersing ourselves in such a striving</p>
88 <p>in other words</p>
89 <p>by this preliminary work, here roughly indicated rather than done explicitly</p>
90 <p>where this is still wanting</p>
91 <p>since the form belonging to a systematic order of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice> is part of this idea</p>
92 <p>in the broadest sense</p>
93 <p>as we have said</p>
94 <p>in the attitude established by transcendental reduction</p>
95 <p>in a maximally broad sense</p>
96 <p>if we maintain this attitude</p>
97 <p>in the broadest Cartesian sense</p>
98</ref>
99
100<ref id="certainty.clause">
101 <p>it is plain that</p>
102 <p>by immersing ourselves meditatively in the general intentions of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice>, we discover that</p>
103 <p>if we follow up this doubt, it becomes manifest that</p>
104 <p>by virtue of my free epoche with respect to the being of the experienced world, the momentous fact is that</p>
105 <p>yet it must not be overlooked that</p>
106 <p>the fact is that</p>
107 <p>we can be sure that</p>
108 <p>hence it follows without more ado that</p>
109 <p><choice><p><xref id="Ns"/> calls</p><p><xref id="Np"/> call</p></choice> our attention to the fact that</p>
110 <p>we see in advance that</p>
111 <p>the fact is evident<p chance="50">, even apodictically evident,</p> that</p>
112 <p>it becomes evident that</p>
113</ref>
114
115<ref id="throwaway.clause">
116 <p>in an extremely broad sense</p>
117 <p>consequently</p>
118 <p>in respect of this evidence</p>
119 <p>however</p>
120 <p>mediately</p>
121 <p>naturally</p>
122 <p>even with respect to the evidence in which <choice><p><xref id="Ns"/> presents itself</p><p><xref id="Np"/> present themselves</p></choice></p>
123 <p>as a matter of essential necessity</p>
124 <p>perchance</p>
125 <p>when we let our thoughts hasten in this manner</p>
126</ref>
127
128<ref id="how.clause">
129 <p>by conscious conversion into the corresponding <xref id="Np"/></p>
130 <p>by virture of a synthesis in which what is meant coincides and agree with <xref id="Ns"/></p>
131 <p>by a freely actualizable return to <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
132 <p>by reconciling with <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
133 <p>by orienting <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice> according to accured insights</p>
134 <p>by the fundamental nature of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
135</ref>
136
137<ref id="main.clause">
138 <p><xref id="Ns"/><p chance="50">, <xref id="throwaway.clause"/>,</p> <xref id="Vst"/> <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice><p chance="50">; <xref id="subject.clause"/></p></p>
139 <p><xref id="Ns"/><p chance="50"> (<xref id="intro.clause"/>)</p> <xref id="Vsi"/><p chance="50"> <xref id="how.clause"/></p></p>
140 <p><xref id="Np"/><p chance="50">, <xref id="throwaway.clause"/>,</p> <xref id="Vpt"/><p chance="50">, <xref id="how.clause"/>,</p> <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
141 <p><xref id="Np"/><p chance="50"> (<xref id="intro.clause"/>)</p> <xref id="Vpi"/><p chance="50">, <xref id="how.clause"/></p><p chance="50">; <xref id="subject.clause"/></p></p>
142</ref>
143
144<ref id="ego.type">
145 <p>reflecting</p>
146 <p>phenomenological</p>
147 <p>transcendental</p>
148 <p>worldly</p>
149</ref>
150
151<ref id="subject.clause">
152 <p><choice><p>I</p><p>we</p></choice> now shift the weight of transcendental evidence of <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice> <p chance="50">(<xref id="intro.clause"/>) </p>from the <p chance="50"><xref id="ego.type"/> </p>ego to <choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p>
153 <p>we must not let ourselves be frightened by considerations of <xref id="Ns"/> and <xref id="Np"/></p>
154 <p>only in reflection do we "direct" ourselves to <xref id="Ns"/> and to its perceptual directedness to <xref id="Np"/></p>
155 <p>we have not simply lost <xref id="Ns"/> for phenomenology; we retain it<p chance="50">, <xref id="throwaway.clause"/>,</p> <xref id="how.clause"/></p>
156 <p>I have the reflection that <xref id="Ns"/> is given continuously as an objective unity in a multi-form and changeable multiplicity of <xref id="Np"/>, which belong determinately to it</p>
157 <p>I<p chance="50">, the meditating phenomenologist,</p> set myself the all-embracing task of uncovering <choice><p>myself</p><p><choice><p><xref id="Ns"/></p><p><xref id="Np"/></p></choice></p></choice> <xref id="how.clause"/></p>
158</ref>
159
160<ref id="sentence">
161 <p class="sentence"><p chance="50"><xref id="certainty.clause"/> </p><xref id="main.clause"/>.</p>
162 <p class="sentence"><p chance="50"><xref id="certainty.clause"/> </p><xref id="main.clause"/>.</p>
163 <p class="sentence"><p chance="50"><xref id="certainty.clause"/><p chance="50">, <xref id="how.clause"/>,</p> </p><xref id="subject.clause"/>.</p>
164</ref>
165
166<ref id="paragraph">
167 <p> <p chance="50"><xref id="sentence"/> </p><p chance="50"><xref id="sentence"/> </p><p chance="50"><xref id="sentence"/> </p><p chance="50"><xref id="sentence"/> </p><xref id="sentence"/> <xref id="sentence"/> <xref id="sentence"/> <xref id="sentence"/> <xref id="sentence"/>
168</p>
169 <p> <p chance="50"><xref id="sentence"/> </p><p chance="50"><xref id="sentence"/> </p><xref id="sentence"/> <xref id="sentence"/> <xref id="sentence"/> <xref id="sentence"/> <xref id="sentence"/>
170</p>
171 <p> <p chance="50"><xref id="sentence"/> </p><p chance="50"><xref id="sentence"/> </p><p chance="50"><xref id="sentence"/> </p><p chance="50"><xref id="sentence"/> </p><xref id="sentence"/> <xref id="sentence"/> <xref id="sentence"/> <xref id="sentence"/>
172</p>
173</ref>
174
175<ref id="section">
176 <p><xref id="paragraph"/><xref id="paragraph"/><xref id="paragraph"/><xref id="paragraph"/><p chance="50"><xref id="paragraph"/></p><p chance="50"><xref id="paragraph"/></p><p chance="50"><xref id="paragraph"/></p><p chance="50"><xref id="paragraph"/></p><p chance="50"><xref id="paragraph"/></p><p chance="50"><xref id="paragraph"/></p></p>
177</ref>
178</grammar>

3   thanks.xml

Generates random thank-you notes. This is my favorite.

3.1   Example

Dear sister,
This is just a quick note to thank you for the "Critique of Pure Reason" I got from you for our first baby. It looks lovely in my doghouse. It was a little strange to get anything from you at all, because I thought you were in prison.
Sincerely
Alex

3.2   Code

# 's
  1<?xml version="1.0"?>
2<!DOCTYPE grammar PUBLIC "-//diveintopython.org//DTD Kant Generator Pro v1.0//EN" "kgp.dtd">
3<grammar>
4
5<ref id="money.object">
6 <p>new clothes</p>
7 <p>a really good book</p>
8 <p>drugs</p>
9 <p>comic books</p>
10 <p>booze for a party I'm throwing this weekend</p>
11 <p>new computer hardware</p>
12 <p>a stuffed animal</p>
13 <p>a cute little pewter castle with crystals on the towers</p>
14 <p>sexy underwear</p>
15 <p>a bread machine</p>
16 <p>car repairs</p>
17 <p>a digital watch</p>
18 <p>a new pet hamster</p>
19 <p>a new toaster</p>
20 <p>shampoo</p>
21 <p>things for my new baby</p>
22 <p>legal fees</p>
23 <p>my divorce</p>
24 <p>this month's rent</p>
25 <p>food<p chance="50"> <choice><p>for the baby</p><p>for the next <choice><p>week</p><p>few days</p></choice></p></choice></p></p>
26 <p>plastic surgery</p>
27</ref>
28
29<ref id="thank.you.paragraph">
30 <p> <p class="sentence"><xref id="money.thanks"/></p></p>
31 <p> <p class="sentence"><xref id="gift.thanks"/></p></p>
32</ref>
33
34<ref id="closing">
35 <p><xref id="closing.line"/>
36<choice><p><xref id="male.name"/></p><p><xref id="female.name"/></p></choice></p>
37</ref>
38
39<ref id="gift.used">
40 <p>I'm planning to take it to the shooting range the next time I go.</p>
41 <p>I'm sure I will put it to good use.</p>
42 <p>Everyone I know is envious.</p>
43 <p>It looks lovely in my <xref id="room"/>.</p>
44 <p>I've made it the central focus of my <xref id="room"/>.</p>
45 <p>My <xref id="room"/> looked empty without it.</p>
46</ref>
47
48<ref id="money.thanks">
49 <p><xref id="money.received"/> <choice><p><xref id="money.spent"/></p><p><xref id="money.saved"/></p></choice> <xref id="money.tag.line"/></p>
50</ref>
51
52<ref id="male.name">
53 <p>Bob</p>
54 <p>Jim</p>
55 <p>John</p>
56 <p>Fred</p>
57 <p>Elmer</p>
58 <p>Charlie</p>
59 <p>Lester</p>
60 <p>David</p>
61 <p>Mark</p>
62 <p>Andrew</p>
63 <p>Pete</p>
64 <p>Bill</p>
65 <p>William</p>
66 <p>James</p>
67 <p>Richard</p>
68 <p>Scott</p>
69 <p>Nathan</p>
70 <p>Matt</p>
71 <p>Jeff</p>
72 <p>Archie</p>
73 <p>Tom</p>
74 <p>Harry</p>
75 <p>Vinnie</p>
76 <p>Michael</p>
77 <p>Dan</p>
78 <p>Ray</p>
79 <p>Roy</p>
80 <p>Todd</p>
81 <p>Chad</p>
82 <p>Jeremy</p>
83 <p>Jason</p>
84 <p>Kurt</p>
85 <p>Keith</p>
86 <p>Ken</p>
87 <p>Tim</p>
88 <p>Randall</p>
89 <p>Eric</p>
90 <p>Stuart</p>
91 <p>Roger</p>
92 <p>Alex</p>
93 <p>Joel</p>
94 <p>Don</p>
95 <p>Ron</p>
96 <p>Arnold</p>
97 <p>Frank</p>
98 <p>Ted</p>
99 <p>Gary</p>
100 <p>Josh</p>
101 <p>Warren</p>
102 <p>Nick</p>
103 <p>Ben</p>
104 <p>Calvin</p>
105 <p>Martin</p>
106 <p>Jake</p>
107 <p>Ed</p>
108</ref>
109
110<ref id="gift.thanks">
111 <p><xref id="gift.received"/> <xref id="gift.used"/> <xref id="gift.tag.line"/></p>
112</ref>
113
114<ref id="money.amount">
115 <p>$5</p>
116 <p>$10</p>
117 <p>$15</p>
118 <p>$20</p>
119 <p>$25</p>
120 <p>$30</p>
121 <p>$35</p>
122 <p>$40</p>
123 <p>$45</p>
124 <p>$50</p>
125 <p>$75</p>
126 <p>$100</p>
127</ref>
128
129<ref id="female.name">
130 <p>Mary</p>
131 <p>Emily</p>
132 <p>Anne</p>
133 <p>Kathy</p>
134 <p>Natalie</p>
135 <p>Ellen</p>
136 <p>Joan</p>
137 <p>Jean</p>
138 <p>Jill</p>
139 <p>Rachel</p>
140 <p>Kendra</p>
141 <p>Sabina</p>
142 <p>Sheila</p>
143 <p>Jessica</p>
144 <p>Andrea</p>
145 <p>Megan</p>
146 <p>Alison</p>
147 <p>Robin</p>
148 <p>Lynn</p>
149 <p>Joy</p>
150 <p>Wendy</p>
151 <p>Kristin</p>
152 <p>Donna</p>
153 <p>Kim</p>
154 <p>Jen</p>
155 <p>Beth</p>
156 <p>Lisa</p>
157 <p>Angie</p>
158 <p>Sarah</p>
159 <p>Peggy</p>
160 <p>Becky</p>
161 <p>Laura</p>
162 <p>Nicole</p>
163 <p>Melanie</p>
164 <p>Miriam</p>
165 <p>Alicia</p>
166 <p>Sylvia</p>
167 <p>Clara</p>
168 <p>Julie</p>
169 <p>Rhoda</p>
170 <p>Rhonda</p>
171 <p>Greta</p>
172 <p>Amelia</p>
173 <p>Emma</p>
174 <p>Courtney</p>
175 <p>Ashley</p>
176 <p>Stephanie</p>
177 <p>Vicky</p>
178 <p>Lois</p>
179 <p>Thelma</p>
180 <p>Ruth</p>
181 <p>Elizabeth</p>
182 <p>Sandy</p>
183 <p>Stella</p>
184 <p>Carolyn</p>
185 <p>Maria</p>
186 <p>Marjorie</p>
187 <p>Edith</p>
188 <p>Teresa</p>
189 <p>Linda</p>
190 <p>Sue</p>
191 <p>Rose</p>
192 <p>April</p>
193 <p>Frances</p>
194 <p>Dora</p>
195</ref>
196
197<ref id="room">
198 <p>living room</p>
199 <p>bathroom</p>
200 <p>basement</p>
201 <p>bedroom</p>
202 <p>closet</p>
203 <p>kitchen</p>
204 <p>garage</p>
205 <p>attic</p>
206 <p>dining room</p>
207 <p>hallway</p>
208 <p>guest room</p>
209 <p>sewing room</p>
210 <p>office</p>
211 <p>billiard parlor</p>
212 <p>junk drawer</p>
213 <p>backyard</p>
214 <p>doghouse</p>
215</ref>
216
217<ref id="person">
218 <p><xref id="male"/></p>
219 <p><xref id="female"/></p>
220 <p><xref id="female"/> and <xref id="male"/></p>
221 <p><xref id="male"/> and <xref id="female"/></p>
222 <p><xref id="male.name"/> and <xref id="male.name"/></p>
223 <p><xref id="female.name"/> and <xref id="female.name"/></p>
224</ref>
225
226<ref id="magazine">
227 <p>Maxim</p>
228 <p>The New Yorker</p>
229 <p>Time</p>
230 <p>Newsweek</p>
231 <p>Guns and Ammo</p>
232 <p>Esquire</p>
233 <p>GQ</p>
234 <p>Cosmopolitan</p>
235 <p>The American Spectator</p>
236 <p>The Nation</p>
237 <p>Mother Jones</p>
238 <p>Field and Stream</p>
239 <p>Reader's Digest</p>
240 <p>The Journal of the American Chemical Society</p>
241 <p>Mind</p>
242 <p>Discover</p>
243 <p>Games</p>
244 <p>MacWorld</p>
245 <p>New Republic</p>
246 <p>Wired</p>
247</ref>
248
249<ref id="female">
250 <p>Grandma<p chance="50"> <xref id="female.name"/></p></p>
251 <p>Mom</p>
252 <p>Aunt <xref id="female.name"/></p>
253 <p>sister</p>
254 <p><xref id="female.name"/></p>
255 <p><xref id="female.name"/></p>
256 <p><xref id="female.name"/></p>
257</ref>
258
259<ref id="male">
260 <p>Grandpa<p chance="50"> <xref id="male.name"/></p></p>
261 <p>Dad</p>
262 <p>Uncle <xref id="male.name"/></p>
263 <p>brother</p>
264 <p><xref id="male.name"/></p>
265 <p><xref id="male.name"/></p>
266 <p><xref id="male.name"/></p>
267</ref>
268
269<ref id="state">
270 <p>dead</p>
271 <p>in prison</p>
272 <p>in a labor camp in Siberia</p>
273 <p>in the hospital</p>
274 <p>reported missing last month</p>
275 <p>broke</p>
276 <p>destitute</p>
277 <p>in the witness relocation program</p>
278</ref>
279
280<ref id="money.saved">
281 <p>I've already <choice><p>put</p><p>stashed</p></choice> it in <choice><p>the bank</p><p>a shoebox</p></choice><p chance="50"> to save for <xref id="money.object"/></p>.</p>
282 <p><p chance="50">I'd love to spend it, but </p>I'm saving it to buy <xref id="money.object"/>.</p>
283 <p><p chance="50">It's nice to have some "fun money" to spend, but </p>I've decided to save it for <xref id="money.object"/>.</p>
284 <p><p chance="50">I'd love to spend it<p chance="50"><choice><p>immediately</p><p>right away</p></choice></p>, but </p>I need to save up for <xref id="money.object"/>.</p>
285</ref>
286
287<ref id="greeting">
288 <p>Dear <xref id="person"/>,</p>
289</ref>
290
291<ref id="money.tag.line">
292 <p class="sentence">It's not much by today's standards, but every little bit helps!</p>
293 <p class="sentence">It was either that or give it to the poor.</p>
294 <p class="sentence"><xref id="tag.line"/></p>
295 <p class="sentence"><xref id="tag.line"/></p>
296 <p class="sentence"><xref id="tag.line"/></p>
297 <p class="sentence"><xref id="tag.line"/></p>
298 <p class="sentence"><xref id="tag.line"/></p>
299 <p class="sentence"><xref id="tag.line"/></p>
300 <p class="sentence"><xref id="tag.line"/></p>
301</ref>
302
303<ref id="money.received">
304<p class="sentence"><p chance="50">This is </p>just a brief note to <choice><p>say <choice><p>thanks</p><p>"thank you"</p></choice></p><p>thank you</p></choice> for the <xref id="money.amount"/> <choice><p>you sent</p><p>I received from you</p></choice> for <xref id="occasion"/>.</p>
305<p class="sentence">Of all the <choice><p>presents</p><p>gifts</p><p>things</p><p>stuff</p></choice> I <choice><p>received</p><p>got</p></choice> for <xref id="occasion"/>, I <choice><p>liked</p><p>loved</p></choice> your <p chance="50">gift of </p><xref id="money.amount"/> <choice><p>the most</p><p>more than anything else</p></choice>.</p>
306<p class="sentence">I <p chance="50">really </p><choice><p>appreciate</p><p>enjoyed receiving</p></choice> the <xref id="money.amount"/> you <choice><p>gave</p><p>sent</p></choice> me for <xref id="occasion"/>.</p>
307<p class="sentence">I <p chance="50">really </p>love <choice><p>getting</p><p>receiving</p></choice> money for <xref id="occasion"/>, <choice><p>since</p><p>because</p></choice> <choice><p>that</p><p>it</p></choice> means I can <p chance="50">always </p><p chance="50">go out and </p><choice><p>spend it on</p><p>use it for</p></choice> what I really <choice><p>want</p><p>need</p></choice>. <choice><p>Thanks</p><p>Thank you</p></choice> for the <xref id="money.amount"/>.</p>
308<p class="sentence">You can't imagine how surprised I was to discover that you had sent me <xref id="money.amount"/> for <xref id="occasion"/>.</p>
309<p class="sentence"><choice><p>Thanks</p><p>Thank you</p></choice> for the <xref id="money.amount"/><choice><p>. I</p><p>; i</p></choice>t was <choice><p>the perfect</p><p>a great</p></choice> <choice><p>present</p><p>gift</p></choice> for <xref id="occasion"/>.</p>
310<p class="sentence">I don't know how to thank you <p chance="50"><choice><p>properly</p><p>enough</p></choice> </p>for the <xref id="money.amount"/> you <choice><p>sent</p><p>gave</p></choice> <p chance="50">me </p>for <xref id="occasion"/>.</p>
311<p class="sentence">I'm <p chance="50">just </p>writing to say <choice><p>thanks</p><p>"thank you"</p></choice> for the <xref id="money.amount"/> you <p chance="50">graciously </p><choice><p>gave</p><p>sent</p></choice> me for <xref id="occasion"/>.</p>
312<p class="sentence"><choice><p>Thank you</p><p>Thanks</p></choice> for the <xref id="money.amount"/> you <choice><p>bestowed upon</p><p>sent</p></choice> me for <xref id="occasion"/>.</p>
313<p class="sentence"><p chance="50">This is </p>just a quick note to <choice><p>say "thank you"</p><p>thank you</p></choice> for the <xref id="money.amount"/> <choice><p>I <choice><p>got</p><p>received</p></choice> from you</p><p>you sent<p chance="50"> me</p></p></choice> for <xref id="occasion"/>.</p>
314</ref>
315
316<ref id="gift.received">
317<p class="sentence"><p chance="50">This is </p>just a brief note to <choice><p>say <choice><p>thanks</p><p>"thank you"</p></choice></p><p>thank you</p></choice> for the <xref id="gift.object"/> <choice><p>you sent</p><p>I received from you</p></choice> for <xref id="occasion"/>.</p>
318<p class="sentence">Of all the <choice><p>presents</p><p>gifts</p><p>things</p><p>stuff</p></choice> I <choice><p>received</p><p>got</p></choice> for <xref id="occasion"/>, I <choice><p>liked</p><p>loved</p></choice> your <p chance="50">gift of </p><xref id="gift.object"/> <choice><p>the most</p><p>more than anything else</p></choice>.</p>
319<p class="sentence">I <p chance="50">really </p><choice><p>appreciate</p><p>enjoyed receiving</p></choice> the <xref id="gift.object"/> you <choice><p>gave</p><p>sent</p></choice> me for <xref id="occasion"/>.</p>
320<p class="sentence">I <p chance="50">really </p>love <choice><p>getting</p><p>receiving</p></choice> money for <xref id="occasion"/>, <choice><p>since</p><p>because</p></choice> <choice><p>that</p><p>it</p></choice> means I can <p chance="50">always </p><p chance="50">go out and </p><choice><p>spend it on</p><p>use it for</p></choice> what I really <choice><p>want</p><p>need</p></choice>. <choice><p>Thanks</p><p>Thank you</p></choice> for the <xref id="gift.object"/>.</p>
321<p class="sentence">You can't imagine how surprised I was to discover that you had sent me <xref id="gift.object"/> for <xref id="occasion"/>.</p>
322<p class="sentence"><choice><p>Thanks</p><p>Thank you</p></choice> for the <xref id="gift.object"/><choice><p>. I</p><p>; i</p></choice>t was <choice><p>the perfect</p><p>a great</p></choice> <choice><p>present</p><p>gift</p></choice> for <xref id="occasion"/>.</p>
323<p class="sentence">I don't know how to thank you <p chance="50"><choice><p>properly</p><p>enough</p></choice> </p>for the <xref id="gift.object"/> you <choice><p>sent</p><p>gave</p></choice> <p chance="50">me </p>for <xref id="occasion"/>.</p>
324<p class="sentence">I'm <p chance="50">just </p>writing to say <choice><p>thanks</p><p>"thank you"</p></choice> for the <xref id="gift.object"/> you <p chance="50">graciously </p><choice><p>gave</p><p>sent</p></choice> me for <xref id="occasion"/>.</p>
325<p class="sentence"><choice><p>Thank you</p><p>Thanks</p></choice> for the <xref id="gift.object"/> you <choice><p>bestowed upon</p><p>sent</p></choice> me for <xref id="occasion"/>.</p>
326<p class="sentence"><p chance="50">This is </p>just a quick note to <choice><p>say "thank you"</p><p>thank you</p></choice> for the <xref id="gift.object"/> <choice><p>I <choice><p>got</p><p>received</p></choice> from you</p><p>you sent<p chance="50"> me</p></p></choice> for <xref id="occasion"/>.</p>
327</ref>
328
329<ref id="occasion">
330 <p>Christmas</p>
331 <p>Valentine's Day</p>
332 <p>my birthday</p>
333 <p>Easter</p>
334 <p>New Year's</p>
335 <p>Hanukkah</p>
336 <p>our wedding</p>
337 <p>our divorce</p>
338 <p>my half-birthday</p>
339 <p>my confirmation</p>
340 <p>my Bar Mitzvah</p>
341 <p>my debutante ball</p>
342 <p>my coming-out party</p>
343 <p>our first baby</p>
344 <p>my bachelor party</p>
345 <p>my bridal shower</p>
346 <p>our housewarming party</p>
347</ref>
348
349<ref id="gift.tag.line">
350 <p><xref id="tag.line"/></p>
351</ref>
352
353<ref id="tag.line">
354 <p class="sentence">I know how much of a sacrifice this sort of gift is for you.</p>
355 <p class="sentence"><xref id="male.name"/> and <xref id="female.name"/> tried to steal it from me, but I was too quick for them.</p>
356 <p class="sentence"><p chance="50">I'm </p>looking forward to getting your next gift for <xref id="occasion"/>.</p>
357 <p class="sentence"><p chance="50">Frankly, </p>it was <p chance="50">a little </p>strange to get anything from you<p chance="50"> at all</p>, because <choice><p>I thought</p><p>my friends told me that</p></choice> you were <xref id="state"/>.</p>
358 <p class="sentence">How thoughtful of you.</p>
359 <p class="sentence">Give my love to <choice><p><xref id="male.name"/></p><p><xref id="female.name"/></p></choice>.</p>
360 <p class="sentence">Best wishes to you<p chance="50"> and <xref id="person"/></p>.</p>
361</ref>
362
363<ref id="closing.line">
364 <p>Sincerely</p>
365 <p>Love<p chance="50"> always</p>,</p>
366 <p>Thank you<p chance="50"> again</p>,</p>
367 <p>See you soon,</p>
368 <p>Hugs and kisses,</p>
369 <p>From,</p>
370 <p>Thanks<p chance="50"> again</p>,</p>
371 <p>Peace,</p>
372 <p>Faithfully,</p>
373</ref>
374
375<ref id="thank.you.note">
376 <p><xref id="greeting"/>
377<xref id="thank.you.paragraph"/>
378
379<xref id="closing"/></p>
380</ref>
381
382<ref id="money.spent">
383 <p class="sentence"><p chance="50">You'll be happy to know that </p>I've already spent it on <xref id="money.object"/>.</p>
384 <p class="sentence">It<choice><p>'s</p><p> has</p></choice> <p chance="50">already </p>been well-spent on <xref id="money.object"/>.</p>
385 <p class="sentence">My <choice><p>mother</p><p>father</p></choice> insisted that I spend it on <xref id="money.object"/>.</p>
386 <p class="sentence">Now I <p chance="50"> finally</p>have enough money for <xref id="money.object"/>.</p>
387 <p class="sentence"><p chance="50"><choice><p>As soon as I can, </p><p>When I get a chance, </p></choice></p>I'm going <p chance="50">to the mall </p>and spending it on <xref id="money.object"/>.</p>
388 <p class="sentence"><p chance="50">To be honest, </p><choice><p>I tried to get it to the bank</p><p>I wanted to save it</p></choice>, but I <p chance="50">realized I </p><choice><p>needed</p><p>had</p></choice> to spend it on <xref id="money.object"/><p chance="50"> instead</p>.</p>
389 <p class="sentence"><p chance="50">I just wanted to let you know that </p>it's already gone towards <xref id="money.object"/>.</p>
390 <p class="sentence">I <p chance="50"><choice><p>immediately</p><p>rushed right out and</p></choice> </p>spent it on <xref id="money.object"/><p chance="50"> for the first time<p chance="50"> in years</p></p>.</p>
391 <p class="sentence"><p chance="50">As soon as I finish writing this letter, </p>I'm going to put it towards <xref id="money.object"/>.</p>
392 <p class="sentence"><p chance="50">I have to admit that </p>I already spent it on this month's protection.</p>
393</ref>
394
395<ref id="gift.object">
396 <p>toaster</p>
397 <p>blender</p>
398 <p>pajamas</p>
399 <p>wallet</p>
400 <p>umbrella</p>
401 <p>shampoo</p>
402 <p>mouthwash</p>
403 <p>beer</p>
404 <p>disk drive</p>
405 <p>mousepad</p>
406 <p>stereo</p>
407 <p>compact disc</p>
408 <p>dart board</p>
409 <p>bread machine</p>
410 <p>moustache comb</p>
411 <p>fruitcake</p>
412 <p>towel rack</p>
413 <p>bong</p>
414 <p>jigsaw puzzle</p>
415 <p>Star Trek "Picard" doll</p>
416 <p>stuffed animal</p>
417 <p>beanbag chair</p>
418 <p>box of chocolates</p>
419 <p>microwave oven</p>
420 <p>snowblower</p>
421 <p>jacket</p>
422 <p>sweatshirt</p>
423 <p>tie</p>
424 <p>laundry detergent</p>
425 <p>fake tree</p>
426 <p>makeup kit</p>
427 <p>miniature pool table</p>
428 <p>carton of cigarettes</p>
429 <p>basketball</p>
430 <p>fake vomit</p>
431 <p>book</p>
432 <p>subscription to <xref id="magazine"/></p>
433 <p>"Critique of Pure Reason"</p>
434</ref>
435
436</grammar>

4   binary.xml

This is a really simple example that will output a random binary string. Not that exciting, but instructive if you want to make your own grammar files.

4.1   Example

11100011

4.2   Code

# 's
 1<?xml version="1.0"?>
2<!DOCTYPE grammar PUBLIC "-//diveintopython.org//DTD Kant Generator Pro v1.0//EN" "kgp.dtd">
3<grammar>
4<ref id="bit">
5 <p>0</p>
6 <p>1</p>
7</ref>
8<ref id="byte">
9 <p><xref id="bit"/><xref id="bit"/><xref id="bit"/><xref id="bit"/><xref id="bit"/><xref id="bit"/><xref id="bit"/><xref id="bit"/></p>
10</ref>
11</grammar>