It's a pretty simpleminded implementatiation at present.
features i want to add:
act like any other processing utility taking input from stdin
output to stdout
modifying modifiers #this is a nontrivial extension
adding conditionals:
so that lnx++ would cause it to regard the
next token to be a distro identifier
say one of (deb|slk|mdk|rh|sus|esm)
bsd would have the following (frb|opn|net)
adding a line identifier that's ignored by the parser but that
allows it to pick out the euglugcode from the input stream
add options for batch processing, using nonstandard dictionaries
and use in cgi context
l@ _________
ae premise 1: The Truth Makes No Sense ( )__
pr ____( )
rn premise 2: Beauty Is Truth ( )
i. / / / / / / / / / /
co conclusion: Beauty Is Unconscious / / / / / / / / / /
er \@/ http://www.efn.org/~laprice
g |
__________________________/_\_________________________________________________
#!/usr/bin/env python
cd = {
'S' :
{ '+' : 'I know who Seth is.',
'++' : 'Seth taught me everything I know about Linux',
'+++': 'I may be rybolov, Paul Borella, or Rob Hudson',
'*' : 'I am Seth Cohn',
'?' : 'Who is this Seth guy anyway?',
'-' : 'How can someone be so excited about Linux?',
'--': 'I prefer windows for actually getting things done.',
'---': 'I\'m an MCSE. And like applying service packs.',
'!' : 'I am Bill Gates.'}
,
'e' :
{ '+' : 'Emacs is a pretty good text editor',
'++': 'Yow! I can edit text, read mail and play games, without leaving emacs',
'+++': 'I have kbd macros for getting coffee and ordering pizza.',
'*' : 'I\'m getting an implant so that I can run emacs while taking a shower,
climbing a mountain or making love.',
'?' : 'emacs? huh?',
'-' : 'I don\'t think I have enough fingers.',
'--' : 'M-x doctor --if you\'re using emacs that much you need medical help.',
'---': 'WordPerfect is a much better editor.',
'!':'I am Bill Joy.'}
,
'v' :
{ '+' : 'vi is adequate for editing text.',
'++': 'vi\'s sensible command set and responsiveness keep me productive.',
'+++':'I can work faster using vi than most people talk',
'*' : 'If it\'s good enough for Linus it\'s good enough for me.',
'?':'Very Intuitive?',
'-': 'It\'s a Vast Improvement, over ed.',
'--': 'Verrrry Iiiinterestingk. How does it werk?',
'---':'Wouldn\'t it just be easier to use notepad.exe?',
'!':'Improved versions are known as vile,evil and elvis; \'nuff said.'},
'gnu' :
{
'+' : 'I appreciate the work the gnu foundation has done.',
'++' : 'I\'ve submitted bug reports and a patch or two.',
'+++' : 'Every line of code i\'ve ever written is licensed under the GPL.',
'*' : 'I am Richard M. Stallman.',
'?' : 'GNU\'s Not Unix? I don\'t get it.',
'-' : 'I think BSD is a better license.',
'--' : 'GPL infringes on my freedom to innovate.',
'---' : 'Godless Programming Licentiousness, <foaming-at-mouth> this viral
communistic threat to our precious...',
'!' : 'I am Craig Mundie.'}
,
'bsd' :
{
'+' : 'BSD unix has a long history and is well regarded.',
'++' : 'cvsup; make world; is conceptually better than apt-get.',
'+++' : 'Well you DO have to know what you\'re doing.',
'*' : 'OpenBSD is the only OS that\'s secure by default.',
'?' : 'People use an operating system run by demons?',
'-' : 'I prefer system V style systems.',
'--' : 'Full of quirks and strange behaviour accepted as normal operation.',
'---' : 'BSD came from Berkeley, so did LSD, hardly a coincidence.',
'!' : 'Windows 2000 offers all the power of BSD, but is easier to administer.'},
'eug' :
{
'+' : 'I like eugene, it\'s a nice relaxed little college town.',
'++' : 'I go to the country fair every year, take part in some protests and
will partake, socially.',
'+++' : 'cuzz, IIIIiii Wannna BE Anarchy!!!',
'*' : 'I am a Slug Queen, or former Slug Queen.',
'?' : 'Isn\'t that where the anarchist leaders have their conference?',
'-' : 'It\'s a bit hippy-dippy.',
'--' : 'I\'m allergic to trees, patchouli, political correctness and
teargas.',
'---' : 'Eugene is SO Over, all the cool people are moving to Arcata.',
'!' : 'I am John Musumeci.'}
}
import string
class decoder:
def __init__(self):
self.dict = cd
self.tokens = self.dict.keys()
def parse(self,codeblock):
result = {}
l = string.split(codeblock)
for token in l:
segment = []
for letter in token:
if letter in string.letters:
segment.append(letter)
segment = string.join(segment,'')
modifier = string.replace(token,segment,'')
result[segment] = self.dict[segment][modifier]
self.result = result
#return result
def show(self):
trans = {'v':'vi','gnu':'the
GPL','e':'emacs','S':'Seth','bsd':'BSD','eug':'Eugene'}
output = []
for key, value in self.result.items():
output.append("On the topic of %s I think:" % trans[key])
output.append(value)
return string.join(output,'\n')
def main():
import sys
filename = sys.argv[1]
print filename
f = open(filename,'r')
codeblock = string.join(f.readlines(),'')
f.close()
d = decoder()
d.parse(codeblock)
p = d.show()
print p
if __name__=='__main__':
main()