Skip to main content

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
```python
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:

```python
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


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.3.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

hydraseq-0.0.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file hydraseq-0.0.3.tar.gz.

File metadata

  • Download URL: hydraseq-0.0.3.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hydraseq-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d48742ea00301154a22b89d480fa11093e25ec0106f21e55dd89310201d8f262
MD5 f08c875d1dc6f840761e2015575037db
BLAKE2b-256 3f4eed60b32dd8ca1c25884232aae3d21c227e1317810a5cf36fd180fd0c4e23

See more details on using hashes here.

File details

Details for the file hydraseq-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for hydraseq-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2616469aa8106db1b1971ecb09f79491a8b2bcc23ff371e44be757fff4d5ee1a
MD5 3b71805faf0f49e306781f9cd975ffd8
BLAKE2b-256 f5fdf30dc20b18ecb9db0d4bffcc1187094c5657b89921f4b3855fd937d6f5c6

See more details on using hashes here.

Supported by

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