Question: data science/coding question: Part A (1 point) Consider the following grammar beginning with the start symbol S and with the rules S phrase-token phrase-token phrase-token

data science/coding question:

data science/coding question: Part A (1 point) Consider the following grammar beginning

Part A (1 point) Consider the following grammar beginning with the start symbol S and with the rules S phrase-token phrase-token phrase-token tic toc l tic toc What is the set of sentences that is generated by this grammar? Express the "language" generated by this grammar as succinctly as possible. Your answer should be in the same kind of form as our description of the sentences generated by the "nearly" grammar described above, which was (nearly)'finished YOUR ANSWER HERE Part B (1 point) In this problem, you are going to generate random sentences from a grammar. To generate random sentences, you'll need to use a random function from the np.random module In [4]: np.random.rand? This function returns a value that is uniformly distributed between and 1 In [ : np.random.rand () For an example of how to use random numbers in generating random sentences from a grammar, see the adjective phrase function defined above Edit the function tic to generate random sentences from the grammar defined in Part A. In [ def tic(): Generates random sentences using the grammar in Part A. Your answer should include a single space after each tic" and 'toc". Hint: your solution can be done in 5 lines of code (or less), including the return statement. Returns a string representing a sentence from the grammar in Part A # YOUR CODE HERE raise NotImplementedError () Part A (1 point) Consider the following grammar beginning with the start symbol S and with the rules S phrase-token phrase-token phrase-token tic toc l tic toc What is the set of sentences that is generated by this grammar? Express the "language" generated by this grammar as succinctly as possible. Your answer should be in the same kind of form as our description of the sentences generated by the "nearly" grammar described above, which was (nearly)'finished YOUR ANSWER HERE Part B (1 point) In this problem, you are going to generate random sentences from a grammar. To generate random sentences, you'll need to use a random function from the np.random module In [4]: np.random.rand? This function returns a value that is uniformly distributed between and 1 In [ : np.random.rand () For an example of how to use random numbers in generating random sentences from a grammar, see the adjective phrase function defined above Edit the function tic to generate random sentences from the grammar defined in Part A. In [ def tic(): Generates random sentences using the grammar in Part A. Your answer should include a single space after each tic" and 'toc". Hint: your solution can be done in 5 lines of code (or less), including the return statement. Returns a string representing a sentence from the grammar in Part A # YOUR CODE HERE raise NotImplementedError ()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!