def main(): hist = process_file('emma.txt', skip_header=True) words = process_file('words.txt', skip_header=False) diff = subtract(hist, words) print("The words in the book that aren't in the word list are:") for word in diff: print(word, end=' ')
def main(): hist = process_file('emma.txt', skip_header=True) words = process_file('words.txt', skip_header=False) diff = subtract(hist, words) print("Słowa w książce nieobecne na liście słów to:") for word in diff: print(word, end=' ')
def main(script, filename='emma.txt', flag='plot'): hist = process_file(filename, skip_header=True) if flag == 'print': print_ranks(hist) elif flag == 'plot': plot_ranks(hist) else: print('Usage: zipf.py filename [print|plot]')
def main(script, filename='158-0.txt', flag='plot'): hist = process_file(filename, skip_header=True) # either print the results or plot them if flag == 'print': print_ranks(hist) elif flag == 'plot': plot_ranks(hist) else: print('Usage: zipf.py filename [print|plot]')
def main(script, filename='emma.txt', flag='plot'): hist = process_file(filename, skip_header=True) # either print the results or plot them if flag == 'print': print_ranks(hist) elif flag == 'plot': plot_ranks(hist) else: print('Użycie: zipf.py nazwa_pliku [print|plot]')
def main(script, filename='emma.txt', flag='plot'): hist = process_file(filename, skip_header=True) # either print the results or plot them if flag == 'print': print_ranks(hist) elif flag == 'plot': plot_ranks(hist) else: print('Usage: zipf.py filename [print|plot]')
def main(script, filename='1989 O Ano Que Mudou o Mundo - Michael Meyer.txt', flag='plot'): hist = process_file(filename, skip_header=False) # either print the results or plot them if flag == 'print': print_ranks(hist) elif flag == 'plot': plot_ranks(hist) else: print('Usage: zipf.py filename [print|plot]')
def main(): hist = process_file('158-0.txt', skip_header=True) print("\n\nHere are some random words from the book") for i in range(100): print(random_word(hist), end=' ')
def main(): hist = process_file('emma.txt', skip_header=True) print("\n\nNiektóre słowa losowe z książki") for i in range(100): print(random_word(hist), end=' ')
import random from bisect import bisect from analyze_book1 import process_file def random_word(hist): words = [] freqs = [] total = 0 for word in hist: total += hist[word] words.append(word) freqs.append(total) t = random.randint(0, total) index = bisect(freqs, t) return words[index] if __name__ == '__main__': hist = process_file('emma.txt', skip_header=True) print("\n\nHere are some random words from the book") for i in range(100): print random_word(hist),
def main(): hist = process_file('emma.txt', skip_header=True) print("\n\nHere are some random words from the book") for i in range(100): print(random_word(hist), end=' ')