def hello_world():
    num_words = 10
    my_file = ('source.txt')
    my_histogram = tuple_hist(my_file)
    for i in range(num_words):
        word = prob_sample(my_histogram)
    return word
def hello_world():

    my_file = ('source.txt')
    my_histogram = list_hist(my_file)
    word = prob_sample(my_histogram)

    return word
示例#3
0
def hello_world():
    my_file = open("./words.txt", "r")
    lines = my_file.readlines()
    my_histogram = list_histogram(lines)

    word = prob_sample(my_histogram)

    return word
def hello_world():

    my_file = open("./words.txt", "r")
    lines = clean(my_file)
    my_histogram = list_hist(lines)
    word = prob_sample(my_histogram)

    return word
示例#5
0
def hello_world():
    num_words = 10
    sentence = []
    my_file = ('source.txt')
    my_histogram = list_hist(my_file)
    for i in range(num_words):
        word = prob_sample(my_histogram)
        sentence += ' ' + word
    return sentence
示例#6
0
def hello_world():
    num_words=15
    sentence=''
    my_file=('./Code/source.txt')
    my_histogram=tuple_hist(my_file)

    for i in range(num_words):
        word = prob_sample(my_histogram)
        sentence += ' ' + word
    return sentence
    def frequency(self, word):
        """Return frequency count of given word, or 0 if word is not found."""
        # TODO: Retrieve word frequency count
        if word in self:
            freq = self[word]
            return freq

    # def sample(self):
    #     """Return a word from this histogram, randomly sampled by weighting
    #     each word's probability of being chosen by its observed frequency."""
    #     # TODO: Randomly choose a word based on its frequency in this histogram
        return prob_sample(self)
 def sample(self):
     """Return a word from this histogram, randomly sampled by weighting
     each word's probability of being chosen by its observed frequency."""
     # TODO: Randomly choose a word based on its frequency in this histogram
     return prob_sample(self)