I love this idea!! But, I don't think that program is very thorough/accurate, unfortunately. It looks like it has problems with plurals, possessive nouns, and pronouns? I imagine that he meant to at LEAST include the plurals...
I was shocked at how few nouns there were in the State of the Union so I went to compare, and a lot of nouns are nurbled. For example, in the first few paragraphs in the comic, it leaves out "achievements" and "America's" and "Forces" and "institutions" and "expectations" ... etc.
Here's the link to the State of the Union text.
http://www.whitehouse.gov/the-press-off ... on-address
[2012-Oct-30] Nurble
Re: [2012-October-30] Nurble
I think Zach should spell out his name in his chesthair when does pictures like that.
Re: [2012-October-30] Nurble
I wrote a 15-line python script which does the job using the NTLK.
The guys from the Language Log also discussed this issue.
Code: Select all
import ntlk
def nurbleize(sentence):
allowed = ["NNP","NNS","NN"]
punct = [".",","]
result = []
tk = nltk.word_tokenize(sentence)
tg = tltk.pos_tag(tk)
for (w,p) in tg:
if p in allowed:
result += [" "+w.upper()]
elif p in punct:
result += [w]
else:
result += [" nurble"]
return "".join(result)[1:]
- sotic
- [Insert Here]
- Posts: 325
- Joined: Thu Aug 04, 2011 5:55 am
- Location: Wisconsin
- Contact:
Re: [2012-October-30] Nurble
All I got out of this comic was a reminder of how awful PHP is.
Wind catches lily / Scatt'ring petals to the wind: / Segmentation fault
-
- Posts: 2
- Joined: Wed Oct 31, 2012 11:45 am
Re: [2012-October-30] Nurble
Right so. Come on — PHP?? Get decent. Use Python:sotic wrote:All I got out of this comic was a reminder of how awful PHP is.
Code: Select all
#!/usr/bin/env python
import re, sys
with open('part-of-speech.txt') as posFile:
wordKind = dict(line.strip().split('\t') for line in posFile)
def nurble(word):
return word if 'N' in wordKind.get(word, '') else 'nurble'
for line in sys.stdin:
sys.stdout.write(re.sub(r'[a-zA-Z]+', lambda x: nurble(x.group()), line))
Re: [2012-October-30] Nurble
PHP is a pretty decent templating engine, which is what it was designed for.sotic wrote:All I got out of this comic was a reminder of how awful PHP is.
Re: [2012-October-30] Nurble
Server-side nurbling is quite limited because it nurbles only a set of texts on 1 server.
I suggest as general-purpose web nurbling techniques :
I suggest as general-purpose web nurbling techniques :
- either use the server as a proxy : take any URL as a GET parameter, let the server fetch the page, nurble it, and render it
- or create a browser plugin that nurbles everything before rendering