Skip to main content

Simple Python Trie Data Structure

Project description

TriePy
===========

A simple trie implementation in Python

This implementation utilizes a dictionary as its backing
data structure. Essentially, it is creating nested dictionaries.


Example
----------
>>> from trie import TriePy
>>> t = TriePy()
>>> t.addWord("dog")
>>> t.addWord("doggy")
>>> t.addWord("dogs")
>>> t.containsWord("dog")
True
>>> t.containsWord("dogg")
False
>>> t.root
{'d': {'o': {'g': {'!THIS_IS_THE_END!': {'word': 'dog'}, 's': {'!THIS_IS_THE_END!': {'word': 'dogs'}}, 'g': {'y': {'!THIS_IS_THE_END!': {'word': 'doggy'}}}}}}}


Unit Testing
----------
nose is used for unit testing and simple unit tests
can be run with the following in the source trie directory:
`nosetests`


Installation
----------
You can install this as usual with `setup.py`.
`python setup.py install`

You can also install this via pip.
`pip install TriePy`

The usual "use virtualenv to test first" warnings apply.

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

TriePy-0.1.3.tar.gz (1.8 kB view hashes)

Uploaded Source

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