elephant in my pajamas

4 results back to index


pages: 504 words: 89,238

Natural language processing with Python by Steven Bird, Ewan Klein, Edward Loper

bioinformatics, business intelligence, business logic, Computing Machinery and Intelligence, conceptual framework, Donald Knuth, duck typing, elephant in my pajamas, en.wikipedia.org, finite state, Firefox, functional programming, Guido van Rossum, higher-order functions, information retrieval, language acquisition, lolcat, machine translation, Menlo Park, natural language processing, P = NP, search inside the book, sparse data, speech recognition, statistical model, text mining, Turing test, W. E. B. Du Bois

In Chapter 10 we will extend this, to automatically build up the meaning of a sentence out of the meanings of its parts. Ubiquitous Ambiguity A well-known example of ambiguity is shown in (2), from the Groucho Marx movie, Animal Crackers (1930): (2) While hunting in Africa, I shot an elephant in my pajamas. How an elephant got into my pajamas I’ll never know. Let’s take a closer look at the ambiguity in the phrase: I shot an elephant in my pajamas. First we need to define a simple grammar: >>> ... ... ... ... ... ... ... ... ... groucho_grammar = nltk.parse_cfg(""" S -> NP VP PP -> P NP NP -> Det N | Det N PP | 'I' VP -> V NP | VP PP Det -> 'an' | 'my' N -> 'elephant' | 'pajamas' V -> 'shot' P -> 'in' """) 8.1 Some Grammatical Dilemmas | 293 This grammar permits the sentence to be analyzed in two ways, depending on whether the prepositional phrase in my pajamas describes the elephant or the shooting event. >>> sent = ['I', 'shot', 'an', 'elephant', 'in', 'my', 'pajamas'] >>> parser = nltk.ChartParser(groucho_grammar) >>> trees = parser.nbest_parse(sent) >>> for tree in trees: ... print tree (S (NP I) (VP (V shot) (NP (Det an) (N elephant) (PP (P in) (NP (Det my) (N pajamas)))))) (S (NP I) (VP (VP (V shot) (NP (Det an) (N elephant))) (PP (P in) (NP (Det my) (N pajamas))))) The program produces two bracketed structures, which we can depict as trees, as shown in (3): (3) a.

groucho_grammar = nltk.parse_cfg(""" S -> NP VP PP -> P NP NP -> Det N | Det N PP | 'I' VP -> V NP | VP PP Det -> 'an' | 'my' N -> 'elephant' | 'pajamas' V -> 'shot' P -> 'in' """) 8.1 Some Grammatical Dilemmas | 293 This grammar permits the sentence to be analyzed in two ways, depending on whether the prepositional phrase in my pajamas describes the elephant or the shooting event. >>> sent = ['I', 'shot', 'an', 'elephant', 'in', 'my', 'pajamas'] >>> parser = nltk.ChartParser(groucho_grammar) >>> trees = parser.nbest_parse(sent) >>> for tree in trees: ... print tree (S (NP I) (VP (V shot) (NP (Det an) (N elephant) (PP (P in) (NP (Det my) (N pajamas)))))) (S (NP I) (VP (VP (V shot) (NP (Det an) (N elephant))) (PP (P in) (NP (Det my) (N pajamas))))) The program produces two bracketed structures, which we can depict as trees, as shown in (3): (3) a.

So cell (1, 2) will contain the entry V. More generally, if our input string is a1a2 ... an, and our grammar contains a production of the form A → ai, then we add A to the cell (i-1, i). So, for every word in text, we can look up in our grammar what category it belongs to. >>> text = ['I', 'shot', 'an', 'elephant', 'in', 'my', 'pajamas'] [V -> 'shot'] For our WFST, we create an (n-1) × (n-1) matrix as a list of lists in Python, and initialize it with the lexical categories of each token in the init_wfst() function in Example 8-3. We also define a utility function display() to pretty-print the WFST for us. As expected, there is a V in cell (1, 2).


pages: 297 words: 69,467

Dreyer's English: An Utterly Correct Guide to Clarity and Style by Benjamin Dreyer

a long time ago in a galaxy far, far away, Albert Einstein, Donald Trump, Downton Abbey, elephant in my pajamas, In Cold Blood by Truman Capote, Jane Jacobs, Mahatma Gandhi, Nelson Mandela, non-fiction novel, Norman Mailer, pre–internet, Ralph Waldo Emerson, The Death and Life of Great American Cities, W. E. B. Du Bois

No. 9. A sentence whose parts are misarranged to inadvertent comic effect can be a kind of dangler, but mostly I think of it simply as a sentence whose parts are misarranged to inadvertent comic effect. Or to advertent comic effect, if you’re Groucho Marx: “One morning I shot an elephant in my pajamas. How he got into my pajamas, I’ll never know.” Or perhaps you’ve met that famous man with a wooden leg named Smith. 10. You’d be amazed at how far you can get in life having no idea what the subjunctive mood is—as if it’s not bad enough that English has rules, it also has moods—but as long as I’ve brought the subject up, let’s address it.


Comedy Writing Secrets by Mel Helitzer, Mark Shatz

Albert Einstein, built by the lowest bidder, David Sedaris, Donald Trump, elephant in my pajamas, fake news, fear of failure, index card, Kickstarter, lateral thinking, Ronald Reagan, Saturday Night Live, the scientific method, Yogi Berra

Simple Truths and Non Sequiturs Another category of simple-truth humor is the non sequitur, an illogical statement that is humorous because of the juxtaposition of two unrelated elements. "One must have some grasp of logic even to recognize a non sequitur," warned author and professor John Allen Paulos. I shot an elephant in my pajamas. How he got in my pajamas, I'll never know. —Groucho Marx A hundred years from now, the works of the old masters will be a thing of the past. —A. Grove Day Roadhouse sign: Clean and decent dancing every night but Sunday. Store sign: "Big Sale—Last Week!" Why are they telling me this? I already missed it.


pages: 661 words: 187,613

The Language Instinct: How the Mind Creates Language by Steven Pinker

Albert Einstein, Boeing 747, cloud computing, Computing Machinery and Intelligence, David Attenborough, double helix, Drosophila, elephant in my pajamas, finite state, Gregor Mendel, illegal immigration, Joan Didion, language acquisition, Loebner Prize, mass immigration, Maui Hawaii, meta-analysis, MITM: man-in-the-middle, natural language processing, out of africa, phenotype, rolodex, Ronald Reagan, Sapir-Whorf hypothesis, Saturday Night Live, speech recognition, Steven Pinker, Strategic Defense Initiative, tacit knowledge, theory of mind, transatlantic slave trade, Turing machine, Turing test, twin studies, Yogi Berra

I showed you examples like Child’s Stool Is Great for Use in Garden, where the single word stool has two meanings, corresponding to two entries in the mental dictionary. But sometimes a whole sentence has two meanings, even if each individual word has only one meaning. In the movie Animal Crackers, Groucho Marx says, “I once shot an elephant in my pajamas. How he got into my pajamas I’ll never know.” Here are some similar ambiguities that accidentally appeared in newspapers: Yoko Ono will talk about her husband John Lennon who was killed in an interview with Barbara Walkers. Two cars were reported stolen by the Groveton police yesterday.