Ah, 90s background images. |
I decided to use the part-of-speech data to write a program that approximates my special sense of humor by replacing random words with other ones. The idea is pretty simple - for each word, look up what kind of word it is, then replace that word with another one of the same kind - but there were some little hurdles to jump along the way.
A noun |
potato NWhich means "potato" is a noun. No surprise there. But,
light NAVviWhich means "light" is mostly a noun but also an adjective, a verb, and an adverb. And without parsing the whole sentence my program wasn't able to tell which. I didn't want full natural language parsing, we'll save that for another project. Instead I went with a trick: find another word that can also be all of those things.
Oh, but "light" is the only NAVvi word in the set. It wouldn't be very interesting to replace it with itself. Moby sorts the parts-of-speech by likelihood, so I'll trim off the least likely usage and try again. "Square" is marked as "NAVv", so except for the intransitive verb usage, it might fit. One more step, to "NAV" gives 22 more choices, for instance "signal". I might get even more choices if I considered "NAV" words equivalent to, for instance, "AVN", but I haven't tried that yet.
For some words, replacing them with another word really tends to make the sentence strange. For instance, "had" and "been" are both marked "V", but when they appear together they take on particular meaning, and it no longer works to replace one of them with "sparge", say. So I set up a list of words that the program leaves unaltered.
More potatoes. Random. |
Finally, for many words, not all variations of the word were in the data. So my program had to detect the "-ing" forms of verbs, for instance, replace just the base part, and put the "ing" back on the end afterward. It's not very good at that (it thinks the past tense of "choose" is "chooseed"), but it's good enough to play with.
The end result is the page linked below. There are some sample texts you can choose to get started, or enter your own text, and play with the sliders to see what kind of silliness it produces. Or put another way, steer with the phenomenons to stand what conic of fact it dies.
I've moved the page to github, to avoid the Dropbox hack.
ReplyDelete