Simple data structure for sequence memory
Project description
hydraseq
Simple data structure to remember sequences
Data structure composed of a trie embedded in dictiories for easy lookup. Basic function is to keep track of sequences given and then return the next expected in a sequence if already seen.
Example usage
from hydraseq import Hydraseq
hdr = Hydraseq('main')
hdr.predict("The quick brown fox jumped over the lazy dog", is_learning=True)
assert hdr.predict("The quick brown").sdr_predicted == ['fox']
hdr.predict("The quick brown cat jumped over the lazy dog", is_learning=True)
assert hdr.predict("The quick brown").sdr_predicted == ['cat', 'fox']
Some notes on usage
- The is_learning flag means it will remember this sequence. This is so you can then use it later to check predicted next words in a read only mode. Otherwise it would just remember all the tried sequences.
- The input is either a sentence which gets space separated, as in the example above, or it can also be a list.
- When learning a new sequence as in the following example:
hdr = Hydraseq('main')
hdr.predict([['a'], ['b', 'c'], ['d'], ['e']], is_learning=True)
assert len(hdr.active) == 1
assert len(hdr.predicted) == 0
hdr.predict([['a']], is_learning=False)
assert len(hdr.active) == 1
assert len(hdr.predicted) == 2
hdr.predict([['a'], ['b', 'f']], is_learning=False)
assert len(hdr.active) == 1
assert len(hdr.predicted) == 1
hdr.predict([['a'], ['b', 'c'],['d']])
assert len(hdr.active) == 1
assert len(hdr.predicted) == 1
assert hdr.sdr_predicted == ['e']
hdr.predict([['a'], ['b']])
assert len(hdr.active) == 1
assert len(hdr.predicted) == 1
assert hdr.sdr_predicted == ['d']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hydraseq-0.0.4.tar.gz
(3.4 kB
view details)
Built Distributions
hydraseq-0.0.4-py3.6.egg
(7.2 kB
view details)
File details
Details for the file hydraseq-0.0.4.tar.gz
.
File metadata
- Download URL: hydraseq-0.0.4.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6687be37c220438a0fcf802817cca13102e538977db76ab492803d2b25cbae0b |
|
MD5 | 4e2522d50f9d8131e4b74d3d6d79f8e5 |
|
BLAKE2b-256 | 1f24ed5b49780bd481ef78ff31e1e8c33000ea65d6a8f44bb05fce1df5734287 |
File details
Details for the file hydraseq-0.0.4-py3.6.egg
.
File metadata
- Download URL: hydraseq-0.0.4-py3.6.egg
- Upload date:
- Size: 7.2 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 516be3262f74a03d53865d12bbc7cdf7d2b28bc92597e81da560e6bd3020c83a |
|
MD5 | a4b27550bc891bba62383a02101e5d59 |
|
BLAKE2b-256 | a7fdc9c834d8ae2ad7755b5c7379cc901d5d675b54dfa9c3b2184ab01f5b306f |
File details
Details for the file hydraseq-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: hydraseq-0.0.4-py3-none-any.whl
- Upload date:
- Size: 4.6 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.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84863f8aa9c85bc448818fb7044f6c2871d89d74a5a050ddbf792d9ff67081c3 |
|
MD5 | 1ec3731c10cab7988ebbfc0e37aba8e3 |
|
BLAKE2b-256 | 24d754209a7aaafdff44dbab7282652ff51a0f2db1b484dc777f0c895db4cb97 |