Computer scienceData scienceNLPFormal grammar

Deep understanding of context-free grammar

Correct grammar

Report a typo

The input dataset has a long sentence (only 1 sentence is given in all inputs). You have the following grammar rules:

S -> Clause Conj Clause Stop
Clause -> NP Adv VP

NP -> Noun
VP -> Verb | VP Adj | VP Adj Adv

Adv -> 'usually' | 'very' | 'sometimes'
Pronoun -> 'he'
Verb -> 'is' | 'be'
Modal -> 'can'
Adj -> 'diplomatic' | 'unkind'
Conj -> 'but'
Comma -> ','
Stop -> '.'

However, this grammar has bugs. Find the bugs and fix them. Please, do not edit names for elements.

In the end, you need to get the following tree:

Tree

Provide a standard NLTK printed output as the answer.

Write code in your IDE to process the text file and display the results below
___

Create a free account to access the full topic