Для себя Task is about phrase-structure syntax, formal semantics and parsers for them. The materials can be found in chapters 17 and 19 of Jurafsky & Martin's book and in chapter 8 to 10 of NLTK book. Assaignment 1. Collect the probabilistic grammar from Penn treebank corpus (nltk.corpus.treebank) using nltk.Tree.productions() and nltk.induce_pcfg(). Save the grammar to a file. Create a parser based on the grammar and try to parse some English sentences with it. If the parser fails because of missing words in the vocabulary, replace the words in the sentence with similar words of the same category. After that - does the parser create reasonably correct trees? 2. Write a function that generates a random sentence based on a given probabilistic grammar. You can use grammar.start() to identify the starting symbol of the grammar (normally S) and grammar.productions(lhs) to get all the productions with the same left hand side (lhs). Production.prob() method will give you the probability. Generate some sentences from the grammar collected in the previous task. Do they look reasonably grammatical? Based on your experiments with the grammar in tasks 1 and 2 - what are the strong and weak points of the collected grammar? 3. For the following discourse create a grammar which translates the sentences into predicate logic. Manually create a model to check the truth of the resulting formulas. A black kitten saw a mouse. The kitten rushed after it. The mouse jumped into a jar [of flour]. The kitten followed it. The mouse ran away. A white kitten got out of the jar. You can omit the part in the square brackets if there is a problem with it. Treat the article 'the' as the quantifier 'exists unique'. The lambda expression for it would be \P Q.exists x.((P(x) & Q(x)) & all y.(P(y) -> (x = y))). If there is a problem with the pronoun 'it', you can replace it with the noun phrase 'the mouse' directly in the text and process the modified discourse. Take the following grammar as an example: nltk.data.show_cfg('grammars/book_grammars/discourse.fcfg')