Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Jill points out to Jack that English grammar allows a noun to be modified by zero or more adjectives. Examples are The girl hit the
Jill points out to Jack that English grammar allows a noun to be modified by zero or more adjectives. Examples are The girl hit the ball,The girl hit the red ball, and The girl hit the little red ball. She asks Jack to design and implement a function to generate noun phrases based on the following grammar rules:
nounphrase article adjectivephrase noun
adjectivephrase adjective adjectivephrase
where an adjective phrase is one or more adjectives remember that the brackets indicate an optional item in a grammar rule Jacks code for the nounPhrase and adjectivePhrase functions follows:
#nounphrase article adjectivephrase noun
def nounPhrase:
Builds and returns a noun phrase."""
return random.choicearticles
adjectivePhrase random.choicenouns
#adjectivephrase adjective adjectivephrase
def adjectivePhrase:
Builds and returns an adjective phrase."""
return random.choiceadjectives adjectivePhrase
When Jack tests the nounPhrase function, the PVM halts the program with a RecursionError. Determine why this error occurs and correct it
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started