@@ -97,20 +97,19 @@ def create_sentence(start_token, stop_tokens, dictionary):
9797 # print("This is my dictionary", dictionary)
9898 # stop when current_token is a stop token
9999 while current_token not in stop_tokens or len (sentence ) <= 8 :
100- for key , value in dictionary .items ():
101- if key == current_token :
102- # sample from histogram of values
103- cumulative = sample .cumulative_distribution (value )
104- sample_word = sample .sample (cumulative )
105- # add new sample to sentence_list
106- sentence .append (sample_word )
107- # assign second word of key and value to current token
108- # this is hard coded; must be changed to fit the order number
109- # I am unpacking the current token
110- (current_token_one , current_token_two , current_token_three ) = current_token
111- current_token = (current_token_two , current_token_three , sample_word )
112- # get out of for loop and start process over
113- break
100+ if current_token in dictionary :
101+ value = dictionary [current_token ]
102+ # sample from histogram of values
103+ cumulative = sample .cumulative_distribution (value )
104+ sample_word = sample .sample (cumulative )
105+ # add new sample to sentence_list
106+ sentence .append (sample_word )
107+ # assign second word of key and value to current token
108+ # this is hard coded; must be changed to fit the order number
109+ # I am unpacking the current token
110+ (current_token_one , current_token_two , current_token_three ) = current_token
111+ current_token = (current_token_two , current_token_three , sample_word )
112+ # get out of for loop and start process over
114113 return sentence
115114
116115def logger (file ):
0 commit comments