How to use the bidict._bidict.bidict function in bidict

To help you get started, we’ve selected a few bidict 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 IEMLdev / ieml / ieml / lexicon / paths / constants.py View on Github external
from bidict._bidict import bidict

COORDINATES_KINDS = ('t', 's', 'a', 'm', 'r', 'f')

RANKS = bidict({
    0: 'Term',
    1: 'Word',
    2: 'Sentence',
    3: 'SuperSentence',
    4: 'Text'
})

KIND_TO_RANK = {
    't': RANKS.inv['Text'],
    'r': RANKS.inv['Word'],
    'f': RANKS.inv['Word']
}
github IEMLdev / ieml / scripts / export.py View on Github external
def _get_drupal_utils():
    global _drupal_utils
    if _drupal_utils is None:
        _drupal_utils = {
            'drupal_dico': [ieml_term_model(t) for t in Dictionary()]
        }
        _drupal_utils['all_uuid'] = bidict({
                d['IEML']: 1000 + int(hashlib.sha1(d['IEML'].encode()).hexdigest(), 16) % MAX_TERMS_DICTIONARY for d in _drupal_utils['drupal_dico']
        })

    return _drupal_utils
github jab / bidict / bidict / _loose.py View on Github external
"""Implements :class:`bidict.LooseBidict`."""

from ._common import OVERWRITE
from ._bidict import bidict
from ._ordered import OrderedBidict


class LooseBidict(bidict):
    """Mutable bidict with *OVERWRITE* duplication behaviors by default."""

    _on_dup_val = OVERWRITE
    _on_dup_kv = OVERWRITE


class LooseOrderedBidict(OrderedBidict, LooseBidict):
    """Mutable ordered bidict with *OVERWRITE* duplication behaviors by default."""
github jab / bidict / bidict / _named.py View on Github external
def namedbidict(typename, keyname, valname, base_type=bidict):
    r"""Create a new subclass of *base_type* with custom accessors.

    Analagous to :func:`collections.namedtuple`.

    The new class's ``__name__`` and ``__qualname__``
    will be set based on *typename*.

    Instances of it will provide access to their
    :attr:`inverse `\s
    via the custom *keyname*\_for property,
    and access to themselves
    via the custom *valname*\_for property.

    *See also* the :ref:`namedbidict usage documentation
    `
github jab / bidict / bidict / _collapsing.py View on Github external
from ._bidict import bidict

class collapsingbidict(bidict):
    """
    A mutable bidict which does not raise :class:`bidict.CollapseException`
    but rather allows collapses to succeed without warning.
    """
    def _put(self, key, val):
        return super(self.__class__, self).forceput(key, val)