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. Keep track of sequences given and then return the next expected in a sequence if already seen.

## Installation
`pip install hydraseq`

## Example usage
Insert a sentence, and the query to see what the next word is if you submit part of the sentence. This basically rewinds the sentence up to that point and looks up what the next word would be.
```python
from hydraseq import Hydraseq

hdr = Hydraseq('main')

hdr.insert("The quick brown fox jumped over the lazy dog")

print(hdr.look_ahead("The quick brown").get_next_values())
> ['fox']
```

If you now insert a similar sentence, say use `wolf` instead of `fox`, the look ahead will return both.
```python

hdr.insert("The quick brown wolf jumped over the lazy dog")

print(hdr.look_ahead("The quick brown").get_next_values())

> ['fox', 'wolf']
```

## Stepping through word by word
The look_ahead rewinds from the start and stops at the last word, this is not too efficient. You can do a reset, rewinding the start and setp through word by word recovering which words are next.

```python
word = ["The"]
hdr.reset()
while word:
print(word)
word = hdr.hit(word[0]).get_next_values()

print(".")
>
>['The']
>['quick']
>['brown']
>['fox', 'wolf']
>['jumped']
>['over']
>['the']
>['lazy']
>['dog']
>.
```

## Checking state, without actually inserting new words.
Every time you use `insert` the sequence is remembered. If you just want to check what is next but make sure the insert doesn't cause new words to get remembered use the `is_learning=False` flag for both `insert` and `hit`


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

Uploaded Source

Built Distribution

hydraseq-0.0.7-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hydraseq-0.0.7.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.4.3

File hashes

Hashes for hydraseq-0.0.7.tar.gz
Algorithm Hash digest
SHA256 2d554d45db5050659065ddf75e04c5ea3c7d4e5f4d6ba23735859a81c1eb97d1
MD5 fb60e6a304c2cf334d174cbd0aa3db44
BLAKE2b-256 4d1b8b9d6d1ef32191776fb2a116e6504dd43b1ba4c3b93e3603f5a2a0966ed7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hydraseq-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.4.3

File hashes

Hashes for hydraseq-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7cab772986fbc6ee1d8397c117ad6b4c14e95d5770ff0e3a76467fb0459870cb
MD5 9f3db287f79d8d3f0b03790f1a9e7fbb
BLAKE2b-256 0ef98a2d386b88e26033986c0ffdd4903181bc53d191f9b54dafcd9d22fed90f

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