我想建立一个通用的后缀树。我正在使用http://www.daimi.au.dk/~mailund/suffix_tree.html进行此实现。我的代码如下:
s1 = u'abcd'
x = 36
for i in range(x):
listing.append(s1)
stree = GeneralisedSuffixTree(listing)
对于 x = 35 的值,代码工作正常,但对于 x = 36 或更多,我得到以下错误
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-36-e7b83eadb302> in <module>()
6 listing.append(s1)
7
----> 8 stree = GeneralisedSuffixTree(listing)
9
10 count = []
/home/darshan/anaconda/lib/python2.7/site-packages/suffix_tree.pyc in __init__(self, sequences)
113 self.sequences += [u'']
114
--> 115 SuffixTree.__init__(self,concatString)
116 self._annotateNodes()
117
/home/darshan/anaconda/lib/python2.7/site-packages/suffix_tree.pyc in __init__(self, s, t)
60 must not contain the special symbol $.'''
61 if t in s:
---> 62 raise "The suffix tree string must not contain terminal symbol!"
63 _suffix_tree.SuffixTree.__init__(self,s,t)
64
TypeError: exceptions must be old-style classes or derived from BaseException, not str
例外来自此文件https://github.com/Yacoby/suffix-tree-unicode/blob/master/suffix_tree.py
我不明白为什么它适用于值 x < 36 但不适用于其他值。请帮助我了解这里发生了什么。