text = "ALICE was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, " Using R This is a bi-gram write a function that predicts a set of possible next words in a given partial sentence. The function will take three inputs: (1) sentence: the starting of a sentence as a character string, ex. “Hello, how are” and (2) n: the number of words to return that might come next in the sentence. The first returned word should have the highest probability of coming next, the second word should have the second highest probability, and so on. (3) trans_mat: a transition matrix from a previously fitted markov model. The function should base its predictions on the last bigram of the partial sentence. Note: if there are less than n words that can be generated based on the text, then have your function only return these.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

text = "ALICE was beginning to get very tired of
sitting by her sister on the bank, and of having
nothing to do: once or twice she had peeped into
the book her sister was reading, but it had no
pictures or conversations in it, "

Using R

This is a bi-gram

write a function that predicts a set of possible next
words in a given partial sentence.
The function will take three inputs:
(1) sentence: the starting of a sentence as a character string, ex. “Hello, how are” and
(2) n: the number of words to return that might come next in the sentence. The first
returned word should have the highest probability of coming next, the second word
should have the second highest probability, and so on.
(3) trans_mat: a transition matrix from a previously fitted markov model.
The function should base its predictions on the last bigram of the partial sentence.
Note: if there are less than n words that can be generated based on the text, then have your
function only return these. 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr