コード例 #1
0
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=' ')
コード例 #2
0
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=' ')
コード例 #3
0
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(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]')
コード例 #5
0
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]')
コード例 #6
0
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]')
コード例 #7
0
ファイル: zipf.py プロジェクト: 2ndFloorStuff/ThinkPython2
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]')
コード例 #8
0
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]')
コード例 #9
0
ファイル: analyze_book3.py プロジェクト: Noysena/ThinkPython3
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=' ')
コード例 #10
0
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=' ')
コード例 #11
0
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),
コード例 #12
0
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=' ')