This assignment is due Wednesday, November 2 at 11:59PM.

Goals

Through this assignment you will:

Background

Please review the class slides and readings in the textbook on feature-based grammars and parsing. Also, review Chapter 9 of the NLTK book for additional detail on feature structures and feature-based parsing in NLTK. A discussion of aspect, relevant to the last few test sentences can be found in J&M 17.4.2 (15.4.2 in SLP3)

NOTE: The NLTK book contains a discussion of HPSG-style handling of subcategorization. However, this framework is *NOT* implemented in NLTK as it stands. An analogous list structure using [FIRST=?a,REST=?b] pseudo-lists can achieve the same effect, but this should be considered an extra-credit option to be explored if you have spare time. It is not required for this assignment.

Building a Feature-based Grammar

Based on the materials above, create a set of context-free grammar rules augmented with features in the NLTK .fcfg format that are adequate to analyze a small set of English natural language sentences. Sample grammars may be found in the NLTK Book Chapter 9 text, in the mini example file referenced below, and in some of the NLTK grammars under /corpora/nltk/nltk-data/grammars. The grammar should be loadable with nltk.data.load().

Your grammar should be able to parse all well-formed sentences in the provided test sentence file and reject all ill-formed sentences in the list. Your grammar should use rules and features that are linguistically motivated (e.g. phrase structures that we've seen; features based on things like gender, number, animacy, aspect, etc). One way of thinking about this: while you will be evaluated on the set of judgments in sentences_key.txt (see below), your grammar should have broader coverage than that.

Parsing

Create a program to parse the example sentences based on your grammar and analyze the results. Specifically, your program should:

Note: If the sentence is ambiguous, you only need to print a single parse.

Programming

Create a program called hw5_parser.sh which performs the feature parsing grammar check described above invoked as:
hw5_parser.sh <input_grammar_filename> <input_sentence_filename> <output_filename> where,

Files

Please adhere to the naming conventions below:

Example and Test Data Files

All data and example files may be found in /dropbox/22-23/au571/hw5/.

Submission Files

Handing in your work

All homework should be handed in using the Canvas submission tools.