How to use the ural.lru.serialization.unserialize_lru function in ural

To help you get started, we’ve selected a few ural examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github medialab / ural / ural / lru / __init__.py View on Github external
def lru_to_url(lru):

    # Handling both stems and serialized lru
    if isinstance(lru, string_type):
        stems = unserialize_lru(lru)
    else:
        stems = lru

    # Indexing stems
    stems_index = {}

    for stem in stems:
        tag, value = stem.split(':', 1)

        if tag == 'h' and tag in stems_index:
            stems_index[tag] = value + '.' + stems_index[tag]
        elif tag == 'p' and tag in stems_index:
            stems_index[tag] += '/' + value
        else:
            stems_index[tag] = value
github medialab / ural / ural / lru / trie.py View on Github external
def ensure_lru_stems(lru):
    if isinstance(lru, string_type):
        return unserialize_lru(lru)

    return lru