def test_rewrite_sparse(): stats = constant_width.wordlist_stats('tests/lists/sparsewordlist.txt') constant_width.rewrite('tests/lists/sparsewordlist.txt', 'tests/lists/sparsewordlist.bin', stats) seed = mdpants.get_seed() indices = mdpants.get_indices(seed, 3) text_words = mdpants.fetch_words('tests/lists/sparsewordlist.txt', indices, 'text') binary_words = mdpants.fetch_words('tests/lists/sparsewordlist.bin', indices, 'binary') assert text_words == binary_words
def test_extract_sparse_words(): count = mdpants.len_wordlist('tests/lists/sparsewordlist.txt') words = mdpants.fetch_words('tests/lists/sparsewordlist.txt', [0.0 / count, 4.0 / count, 22.0 / count], 'text') assert words == ['Aa', 'Aahing', 'Aasvogels']
def test_extract_words(): count = mdpants.len_wordlist('tests/lists/wordlist.txt') words = mdpants.fetch_words('tests/lists/wordlist.txt', [0.0 / count, 1.0 / count, 2.0 / count], 'text') assert words == ['Aa', 'Aaa', 'Aah']
def test_extract_sparse_non_ascii(): count = mdpants.len_wordlist('tests/lists/emoticons.txt') words = mdpants.fetch_words('tests/lists/emoticons.txt', [0.0 / count, 8.0 / count, 17.0 / count], 'text') assert words == ['😚', '😢', '😫']