How to use the ngram.get_unigram_score function in ngram

To help you get started, we’ve selected a few ngram examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codysmithd / SAIL / _test_ngram.py View on Github external
import ngram

ngram.load()

while True:
	user_input = input("Enter word to test: ")
	print(ngram.get_unigram_score("<s>", user_input))
</s>
github codysmithd / SAIL / sentence_assembler.py View on Github external
def addWord(i):
	global sentence
	global structure
	global word_options

	if i == len(structure):
		rateSentence()
	else:
		prev = "<s>"
		if i &gt;= 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]) &gt; 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>