Skip to content

dohlee/pysuffixarray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pysuffixarray

Suffix array implementation in python.

Usage

pysuffixarray.core.SuffixArray(string)

Constructs a suffix array.

from pysuffixarray.core import SuffixArray
sa = SuffixArray('MISSISSIPPI')

SuffixArray.suffix_array()

Returns a suffix array.

sa = SuffixArray('MISSISSIPPI')
sa.suffix_array()
>>> [11, 10, 7, 4, 1, 0, 9, 8, 6, 3, 5, 2]

SuffixArray.longest_common_prefix()

Returns an array of longest common prefix(LCP). LCP[i] contains the length of common prefix between SA[i] and SA[i-1].

sa = SuffixArray('MISSISSIPPI')
sa.longest_common_prefix()
>>> [0, 0, 1, 1, 4, 0, 0, 1, 0, 2, 1, 3]

SuffixArray.longest_repeated_substring()

Returns one of the longest repeated substrings within the string.

sa = SuffixArray('MISSISSIPPI')
sa.longest_repeated_substring()
>>> 'ISSI'

About

Suffix array implementation written in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages