Skip to main content

A C implemented Suffix Tree package

Project description

Introduction

This is a Suffix Tree data structure lib implemented in C++, wrapped with python.

Expect for contructing the tree, this lib also provides to construct the query tree for speeding up querying strings.

Install and Build

Install from Pypi

run pip install csuffixtree

Build

You can build this either on linux or windows.

Install Python Package

  1. Build SuffixTreePyBinding solution in Windows
  2. On linux you should go to linux directory, and run make python
  3. under SuffixTreePy directory. run python setup.py install

How to use

You can construct a suffix tree in the following way.

from suffixtree import *
tree = SuffixTree(True,["abc","123","321"])
tree.addStrings(["xyz","abcd"])
print(tree.findString("1"))
print(tree.findString("a"))

If you finished inserting strings to a suffix tree, and you want the querying be very fast you can do:

# convert tree to query tree, this release a part of memory
qtree = tree.createQueryTree()
qtree.cacheNodes() # take some time to cache intermediate nodes
qtree.findString("a")

For simplicity you can also write

# do not preserve string
qtree = SuffixQueryTree(False,["abc","abcd","123","321"])
idx = qtree.findStringIdx("abc") # you cannot use findString now
print(idx)

Serialization

SuffixQueryTree can be serialized and deserialized to/from a file a bytes object. For example:

# do not preserve string
qtree = SuffixQueryTree(False,["abc","abcd","123","321"])
idx = qtree.findStringIdx("abc") # you cannot use findString now
print(idx)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csuffixtree-0.1.2.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

csuffixtree-0.1.2-py3-none-any.whl (478.9 kB view details)

Uploaded Python 3

File details

Details for the file csuffixtree-0.1.2.tar.gz.

File metadata

  • Download URL: csuffixtree-0.1.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for csuffixtree-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a8ce611a2465d6246d7cca194418d9547a7846b6a72afeed13834033058d437d
MD5 6cd9ac7cbbe4ea8458bd6314905746f6
BLAKE2b-256 04f39b2287f5d309ec3811f4014d4b6f5e829ce02f400e7c2094bb6574c14fb3

See more details on using hashes here.

Provenance

File details

Details for the file csuffixtree-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: csuffixtree-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 478.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for csuffixtree-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e0090d0e8427b6a0cea6ae119cb7ea60ba3f83cdfb7cd77fa5589cefaee55740
MD5 68582a185706f23979145f18f5582778
BLAKE2b-256 b1a655ada4800837e259a4bb938cef32e2baf589ab78bc4be9502d427c715e4b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page