Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import ngram
ngram.load()
while True:
user_input = input("Enter word to test: ")
print(ngram.get_unigram_score("<s>", user_input))
</s>
def addWord(i):
global sentence
global structure
global word_options
if i == len(structure):
rateSentence()
else:
prev = "<s>"
if i >= 1:
prev = sentence[i - 1]
for index, word in enumerate(word_options):
if word != "":
if int(word[1]) == structure[i]:
if ngram.get_unigram_score(prev, word[0]) > 0:
sentence[i] = word[0]
temp = word
word_options[index] = "" # remove from the list
addWord(i+1)
word_options[index] = temp # add back to the list
</s>