Source

dawg / test_trie.py

Full commit
from dawg import find_word, build_trie

def test_struct():
    for word in (
        "dogs",
        "cats",
        "aslkfjndsak",
        "asfaaks",
        "abject",
        "ablation",
        "ablyation",
        "foober",
        "ountry",
        "countr",
        "country",
        "countries"
    ):
        print word, find_word(word)


def test_nodes_equal():
    head = build_trie([
        # at and et are equivalent.  both have tion, tab
        "ation",
        "etion",
        "etab",
        "atab",

        # ab and eb are not.  baca/baca is the same
        # but boob/barb are not.
        "abaca",
        "ebaca",
        "aboob",
        "ebarb",

        # not equiv.  'eg' doesnt have 'q'
        "agaga",
        "egaga",
        "agquorably"
        "egquorabqr"
    ])

    assert head.get("a") != head.get("e")

    assert head.get("at") == head.get("et")

    assert head.get("ab") != head.get("eb")

    assert head.get("ag") != head.get("eg")

    assert head.get("eg") != head.get("ag")