1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
get(key[, default])
----------------------------------------------------------------------
Return the value associated with the key string.
Raise a ``KeyError`` exception if the key is not in the trie and no default is provided.
Return the optional default value if provided and the key is not in the trie.
Example
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: python
>>> import ahocorasick
>>> A = ahocorasick.Automaton()
>>> A.add_word("cat", 42)
True
>>> A.get("cat")
42
>>> A.get("dog")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError
>>> A.get("dog", "good dog")
'good dog'
|