In this problem set we will experiment with DRT and discourse reasoning.
1. We will work with the grammar grammars/book_grammars/drt.fcfg
a. Create a new version of the grammar which is able to parse discourses. Do this by adding a rule which says that a discourse can consist of a discourse followed by a sentence and another rule which says that a discourse can consist of a single sentence. You will also need to change the start symbol of your grammar.
b. Show that your grammar can parse the following discourses represented as strings:
(i) 'Angus owns a dog he barks' (equivalently ('Angus owns a dog ' + 'he barks') if you prefer)
(ii) 'A student owns a dog he barks'
(iii) 'Every student owns a dog he barks'
Do the parsing in the way that is given in the NLTK book as we have gone through in class.
c. Show the DRS's that result from (i)-(iii)
d. Show the result of applying resolve_anaphora to these DRS's. In the case of (iii) resolve_anaphora should raise an error. Explain why you get these results in terms of the availability of antecedents in the DRSs.
2. Use DiscourseTester and the Malt parser in the way described in the book and discussed in class.
a. Show that (iii) (represented as ['Every student owns a dog', 'He barks']) now yields a result with anaphora. (If you're wondering about tags try nltk.help.upenn_tagset('.*') .) Why is this?
b. Unfortunately the discourses (i) and (ii) cause an error due to a bug...
3. Test the examples from Problem set 3 using the discourse tester.
a. Add non-storage versions of the rules you developed in problem set 3 for FraCaS problem 017 to grammars/book_grammars/discourse.fcfg. (You may, if you wish, comment out some of the original rules in the file if you do not need them. This may remove unwanted additional readings.) You can load your grammar with something like the following:
Loading a grammar into DiscourseTester
nltk.DiscourseTester(['An Irishman won the Nobel prize for literature'], reading_command=nltk.CfgReadingCommand(gramfile='myfile.fcfg'))
Remember to use
Clear cache
nltk.data.clear_cache()
if you change your grammar and wish to reload it without restarting Python.
b. Show the reading(s) you get for (iv):
(iv) An Irishman won the Nobel prize for literature
c. Add (v) to the discourse:
(v) An Irishman won a Nobel prize
Use add_sentence checking for consistency or informativity. Which is the relevant check for this example?
d. Add appropriate (an) appropriate formula(e) to grammars/book_grammars/background.fol so that anybody who wins a prize receives an honour. Add to your grammar so that you can parse (vi)
(vi) somebody received an honour
Create a discourse tester object for (iv) and add this background to it in the way specified in the NLTK book and discussed in class. (There is an alternative specified on http://nltk.googlecode.com/svn/trunk/doc/howto/discourse.html at the end of section 5, which may or may not be useful.) Now add the sentence (vi) checking for consistency or informativity as appropriate and show that you have obtained the correct results.