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

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


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

Uploaded Source

Built Distribution

hydraseq-0.0.2-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hydraseq-0.0.2.tar.gz
Algorithm Hash digest
SHA256 225c8c5f36cdd7bd2ca3d132fbf02a7eaf726a4cf0e91d7278e35d968611dc7a
MD5 b1fc3a0ea16d0f6045de3c7ca9fded6e
BLAKE2b-256 9a31c60ea76fabfd62134f867fa9cd726bfb97f7c863d0b581c0578cee8ba0fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hydraseq-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eddfb76f098a5e03b47a61bba4e91382de66d2572dc5dc6a28beb173a016405f
MD5 63a923426c07a5ef42d6f4b20dd0a1d2
BLAKE2b-256 3ba46cbe37d9a5fa606a225dad8214f31beee6f31c8bff2588efe571910ef7aa

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