Ling 571 - Deep Processing Techniques for NLP
Winter 2015
Homework #6: Due 11:59 February 18, 2015
Goals
Through this assignment you will:
- Explore the logic and lambda calculus based representations of natural language semantics.
- Analyze the interaction between semantic attachments and syntactic structure for semantic analysis.
- Gain some further familiarity with NLTK.
- Augment grammars with semantic attachments to produce sentential analyses .
Background
Please review the class slides and readings in the textbook on meaning representation and semantic analysis. Also, review Chapter 10 of the NLTK book for additional detailed examples of logical structures in semantics and the implementation of semantic attachments for some common phenomena in natural language.
Creating Target Semantic Representations
Based on the examples in the text, class slides, and NLTK Chapter 10,
manually create representations in first-order logic for each of the example sentences
in the file (see the files section below). Your representations should employ the event-style semantics
presented in class. These forms constitute the semantic representations
that your grammar and parsing process below should derive.
Building a Grammar with Semantic Attachments
Based on the materials above, create a set of context-free grammar
rules augmented with semantic attachments that are adequate to analyze a
small set of English natural language
sentences and produce appropriate semantic analyses.
Your grammar should be able to produce an appropriate semantic analysis for
each sentence in the file.
Semantic analysis
Create a program to perform semantic analysis on the test sentences based on your grammar and output the results. Specifically, your program should:
- Load your grammar with semantic attachments.
- Read in test sentences to analyze.
- Use the nltk.parse.FeatureChartParser class
to parse and semantically analyze the sentences.
- Write the results to a file.
- For each sentence, output to a file
- the semantic representation of the input sentence.
Note: You only need to print a single representation if the sentence is ambiguous.
Files
Test and Example Data Files
All files related to this assignment may be found on patas in
/dropbox/14-15/571/hw6/, as below:
- semantics_test_sentences.txt: These are the sentences to analyze, first manually and then automatically.
- semantics_example_grammar.fcfg: This file provides examples of the semantic attachment format for NLTK.
- semantics_example_sents.txt: Example sentences corresponding to the output example.
- semantics_example_results: This file provides an example of
the desired output format of semantic analysis.
Your semantics representation file
hw6_sentence_semantics.{txt|pdf}: This file should hold your manually created semantic representations. If you want to use "fancy" symbols, please use a PDF file. You may also choose to use the NLTK-style formatting instead; that can be stored in a .txt file if you wish.
Your grammar file
hw6_semantic_grammar.fcfg: This file should store
the grammar you develop for the "rule-to-rule" semantic analysis model
and should cover the test sentences. It should be written in a format that can be read in by
nltk.data.load(). Sample grammars made be found in NLTK book Chapter 10, the online grammars in /corpora/nltk/nltk-data/grammars/, and
in the examples referenced above.
Automatic Semantic Analysis
Create a program hw6_semantic_analysis.py that reads in your
grammar with semantic attachments, analyses test sentences, and produces results as outlined above. It
should take the parameters as specified below:
- hw6_semantic_grammar.fcfg: The grammar file you created above
covering the example sentences in .fcfg format.
- Test sentence file: The sentences to analyze, one sentence per line.
- hw6_results.out: The output file with the results of
parsing each of the input sentences.
Write-up
Describe and discuss your work in a write-up file. Include problems you came across and how (or if) you
were able to solve them, any insights, special features, and what you learned. Give examples if possible.
If you were not able to complete parts of the project, discuss what you tried and/or what did not work.
This will allow you to receive maximum credit for partial work.
Please name the file readme.{txt|pdf} with a suitable extension.
Testing
Your program must run on patas using:
$ condor-submit hw6.cmd
Please see the CLMS wiki pages on the basics of using the condor
cluster.
All files created by the condor run should appear in the top level of
the directory.
Handing in your work
All homework should be handed in using the class CollectIt.
Use the tar command to build a single hand-in file, named
hw#.tar where # is the number of the homework assignment and
containing all the material necessary to test your assignment. Your
hw1.cmd should be at the top level of whatever directory structure
you are using.
For example, in your top-level directory, run:
$ tar cvf hw6.tar *