Example #1
0
def test_one_string3():
    expected = "Elem(node=None, children=" \
               "Elem(node=a, children=Elem(node=na, children=Elem(node=na, children=Elem(node=1, children=)), Elem(node=1, children=)), Elem(node=1, children=)), " \
               "Elem(node=banana, children=Elem(node=1, children=)), " \
               "Elem(node=na, children=Elem(node=na, children=Elem(node=1, children=)), Elem(node=1, children=)))"
    assert expected == str(
        SuffixTree("banana", method=SuffixTreeBuildingMethod.naive))
Example #2
0
def test_three_string():
    expected = "Elem(node=None, children=" \
               "Elem(node=a, children=Elem(node=b, children=Elem(node=a, children=Elem(node=b, children=Elem(node=3, children=)), " \
                    "Elem(node=2, children=)), Elem(node=ba, children=Elem(node=1, children=)), Elem(node=3, children=)), Elem(node=1, children=), Elem(node=2, children=)), " \
               "Elem(node=b, children=Elem(node=a, children=Elem(node=b, children=Elem(node=a, children=Elem(node=2, children=)), " \
                    "Elem(node=3, children=)), Elem(node=1, children=), Elem(node=2, children=)), Elem(node=ba, children=Elem(node=1, children=)), Elem(node=3, children=)))"
    assert expected == str(
        SuffixTree(["abba", "baba", "abab"],
                   method=SuffixTreeBuildingMethod.naive))
Example #3
0
def test_two_string():
    expected = "Elem(node=None, " \
               "children=Elem(node=a, children=Elem(node=na, children=Elem(node=na, children=Elem(node=s, children=Elem(node=2, children=)), " \
                    "Elem(node=1, children=)), Elem(node=s, children=Elem(node=2, children=)), Elem(node=1, children=)), Elem(node=s, children=Elem(node=2, children=)), Elem(node=1, children=)), " \
               "Elem(node=banana, children=Elem(node=1, children=)), " \
               "Elem(node=na, children=Elem(node=na, children=Elem(node=s, children=Elem(node=2, children=)), Elem(node=1, children=)), Elem(node=s, children=Elem(node=2, children=)), Elem(node=1, children=)), Elem(node=s, children=Elem(node=2, children=)))"
    assert expected == str(
        SuffixTree(["banana", "ananas"],
                   method=SuffixTreeBuildingMethod.naive))
Example #4
0
def test_one_letter_string():
    expected = "Elem(node=None, " \
               "children=Elem(node=a, " \
                    "children=Elem(node=a, " \
                        "children=Elem(node=a, " \
                            "children=Elem(node=a, children=Elem(node=1, children=)), " \
                        "Elem(node=1, children=)), " \
                    "Elem(node=1, children=)), " \
               "Elem(node=1, children=)))"
    assert expected == str(
        SuffixTree("aaaa", method=SuffixTreeBuildingMethod.naive))
Example #5
0
from aug.experemental.SuffixTree import SuffixTree, SuffixTreeBuildingMethod

if __name__ == '__main__':
    #tree = SuffixTree(["banana", "ananas"])
    #print(tree.to_graphviz())
    tree = SuffixTree(["manhattan"])
    print(tree.to_graphviz())
    #print(tree.make_common_tree())
    #tree.add("ban")
    #print(tree.to_graphviz())