出现错误“后缀树字符串不能包含终端符号!”

2024-04-18 17:10:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我想建立一个广义后缀树。我使用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值,而不适用于其他值。 请帮助我了解这里发生了什么。你知道吗


Tags: inselftreehomeinitnotsuffixlisting