Ejemplo n.º 1
0
def generate_unigram_sentences(unigram_model, number):
    for i in range(number):
        sentence = ""
        word = None
        while word not in END_SENTENCE_PUNCT:
            word = weighted_random_pick(unigram_model)
            sentence, word = add_word_to_sentence(sentence, word)
        try:
            print sentence
        except:
            print "Could not print sentence due to an unrecognized character."
        print "\n"
Ejemplo n.º 2
0
def word_from_bigram_model_and_previous_word(bigram, word):
	word = weighted_random_pick(bigram[word])
	return word
Ejemplo n.º 3
0
def word_from_trigram_model_and_previous_word(trigram, one, two):
    word = weighted_random_pick(trigram[one][two])
    return word