摘要: To choose a random word from the histogram, the simplest algorithm is to build a list with multiple copies of each word, according to the observed fre... 阅读全文
posted @ 2014-08-17 18:22 平静缓和用胸音说爱 阅读(287) 评论(0) 推荐(0) 编辑
摘要: Finding the words from the book that are not in the word list from words.txt is a problem you might recognize as set subtraction; that is, we want to ... 阅读全文
posted @ 2014-08-17 16:54 平静缓和用胸音说爱 阅读(175) 评论(0) 推荐(0) 编辑
摘要: We have seen built-in functions that take a variable number of arguments. For example range can take one, two or three arguments.It is possible to wri... 阅读全文
posted @ 2014-08-17 16:32 平静缓和用胸音说爱 阅读(316) 评论(0) 推荐(0) 编辑
摘要: To find the most common words, we can apply the DSU pattern; most_common takes a histogram and returns a list of word-frequency tuples, sorted in reve... 阅读全文
posted @ 2014-08-17 16:16 平静缓和用胸音说爱 阅读(211) 评论(0) 推荐(0) 编辑
摘要: Here is a program that reads a file and builds a histogram of the words in the file: process_file loops through the lines of the file, passi... 阅读全文
posted @ 2014-08-17 15:09 平静缓和用胸音说爱 阅读(225) 评论(0) 推荐(0) 编辑