File: automaton_longest_prefix.rst

package info (click to toggle)
python-pyahocorasick 1.4.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 748 kB
  • sloc: ansic: 4,554; python: 2,823; sh: 312; makefile: 242
file content (22 lines) | stat: -rw-r--r-- 527 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
longest_prefix(string) => integer
----------------------------------------------------------------------

Return the length of the longest prefix of string that exists in the trie.

Examples
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python

    >>> import ahocorasick
    >>> A = ahocorasick.Automaton()
    >>> A.add_word("he", True)
    True
    >>> A.add_word("her", True)
    True
    >>> A.add_word("hers", True)
    True
    >>> A.longest_prefix("she")
    0
    >>> A.longest_prefix("herself")
    4