and so now remember that like in order to get the next word we have to set the probability mappings and so this is a great place to do it right before we return the graph object in our make graph function so let's start on this implementation for word in words we're going to check that the word is in the graph and if not then we're going to add it so let's drag URL_TOKEN over here so we can look at both simultaneously okay so you'll see that in get vertex we actually add the vertex already so all we need to do is we can say word vertex equals graph dot get vertex and then that word if there was a previous word then we add an edge if it doesn't exist in the graph otherwise we increment the weight by one so here let's actually create a previous word variable and assign it to none because at the very beginning there is a previous word here we're going to check if previous word then previous word dot increment edge word vertex right because what this is going to do it's going to increment that edge between the previous word and the word vertex by one and here the increment edge already does that for you because we've implemented that in our vertex already now here all we have to do is set previous word equal to whatever this word is so that in our next iteration we have access to the previous word and we keep doing that for all words and at the very end we can say g dot generate probability mappings generate all the probability mappings and then return that graph all right so step two g equals make graph and then we pass in the words that we got from get words from text now step three we want to get the next word for x number of words as defined by the user let's create a function compose given a graph and given the words and some length let's just say NUMBER_TOKEN for now we're going to create a composition and this is at first going to be an empty list every single time that we generate a new word we're just going to put it into this list composition and what we can say is that well look we have the words list let's just get some random word from this words list and you know grab that vertex from g and this is where we're starting so for however many iterations in the length that the user has defined we're just going to iterate and we're going to keep getting the next word right here we can say URL_TOKEN and then this word which is the word vertex we're going to append the value of that vertex because remember we can't actually append the vertex and have that legible we have to append what word that vertex corresponds to and then now our next word is going to be g dot get next word given the current word so here we can say word equals g dot get next word and this current word and what we're going to do is replace this word variable and keep getting the next one at the very end we're just going to return our composition all right now down here in our main function again we can say our composition equals compose we can pass in g we can pass in words and then we can pass in some parameter length override that we can say NUMBER_TOKEN for the heck of it we don't want to just return a list let's actually return a string so we can join this list of words by a space and so this is going to return a
NO_SEGMENT_TOKEN