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:
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)
(NP (Det an) (N elephant) (PP (P in) (NP (Det my) (N pajamas))))))
(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):
Notice that there's no ambiguity concerning the meaning of any of the words; e.g., the word shot doesn't refer to the act of using a gun in the first sentence and using a camera in the second sentence.
* > Your Turn: Consider the following sentences and see if you can think of two quite different interpretations: Fighting animals could be danger' ' | ¿¡|' ous. Visiting relatives can be tiresome. Is ambiguity of the individual words to blame? If not, what is the cause of the ambiguity?
This chapter presents grammars and parsing, as the formal and computational methods for investigating and modeling the linguistic phenomena we have been discussing. As we shall see, patterns of well-formedness and ill-formedness in a sequence of words can be understood with respect to the phrase structure and dependencies. We can develop formal models of these structures using grammars and parsers. As before, a key motivation is natural language understanding. How much more of the meaning of a text can we access when we can reliably recognize the linguistic structures it contains? Having read in a text, can a program "understand" it enough to be able to answer simple questions about "what happened" or "who did what to whom"? Also as before, we will develop simple programs to process annotated corpora and perform useful tasks.
Was this article helpful?