def test_syllables(): tests = test_data.splitlines() tests = [tuple(t.strip().split()) for t in tests if len(t)] tests = [(a, int(b)) for a, b in tests] for t in tests: result = poetryutils2.count_syllables(t[0]) assert result == t[1]
def test_syllables(): tests = test_data.splitlines() tests = [tuple(t.strip().split()) for t in tests if len(t)] tests = [(a, int(b)) for a,b in tests] for t in tests: result = poetryutils2.count_syllables(t[0]) # print('returned %d' % result) if result != t[1]: print(t[0], t[1], result)
def get_lines(source, filters): syllables = (6,9) lines = defaultdict(list) for line in poetryutils2.line_iter(source, filters): c = poetryutils2.count_syllables(line) if c in syllables: lines[c].append(line) return lines