[2012-Oct-30] Nurble

Blame Quintushalls for this.

Moderators: NeatNit, Kimra

User avatar
t-dawg
Posts: 2
Joined: Tue Oct 30, 2012 5:57 pm

[2012-Oct-30] Nurble

Post by t-dawg »

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

pandawaffle

Re: [2012-October-30] Nurble

Post by pandawaffle »

I think Zach should spell out his name in his chesthair when does pictures like that.

L3viathan

Re: [2012-October-30] Nurble

Post by L3viathan »

I wrote a 15-line python script which does the job using the NTLK.

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:]
The guys from the Language Log also discussed this issue.

User avatar
sotic
[Insert Here]
Posts: 325
Joined: Thu Aug 04, 2011 5:55 am
Location: Wisconsin
Contact:

Re: [2012-October-30] Nurble

Post by sotic »

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

Alfe
Posts: 2
Joined: Wed Oct 31, 2012 11:45 am

Re: [2012-October-30] Nurble

Post by Alfe »

sotic wrote:All I got out of this comic was a reminder of how awful PHP is.
Right so. Come on — PHP?? Get decent. Use Python:

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))

guest1

Re: [2012-October-30] Nurble

Post by guest1 »

sotic wrote:All I got out of this comic was a reminder of how awful PHP is.
PHP is a pretty decent templating engine, which is what it was designed for.

Ripounet

Re: [2012-October-30] Nurble

Post by Ripounet »

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 :
  • 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

Post Reply