regexp_learner package

Subpackages

Submodules

regexp_learner.strings module

is_prefix_closed(strings: set) bool[source]

Tests whether a set of strings is prefix-closed (i.e., all the prefixes of all the strings belong to this set).

Example

>>> from regexp_learner import is_prefix_closed
>>> is_prefix_closed({"", "a", "ab", "abc"})
True
>>> is_prefix_closed({"xy", "xyz"})
False
Parameters:

strings (set) – A set of strings.

Returns:

True iff strings is prefix-closed, False otherwise.

is_suffix_closed(str_set) bool[source]

Tests whether a set of strings is suffix-closed (i.e., all the suffixes of all the strings belong to this set).

Example

>>> from regexp_learner import is_suffix_closed
>>> is_suffix_closed({"", "abc", "bc", "c"})
True
>>> is_suffix_closed({"xy", "xyz"})
False
Parameters:

strings (set) – A set of strings.

Returns:

True iff strings is suffix-closed, False otherwise.

prefixes(s: str) iter[source]

Lists all the prefixes of an arbitrary string (including the empty word).

Example

>>> from regexp_learner import prefixes
>>> sorted(prefixes("abcd"))
['', 'a', 'ab', 'abc', 'abcd']
Parameters:

s (str) – A str instance.

Returns:

The prefixes of s.

suffixes(s: str)[source]

Lists all the suffixes of an arbitrary string (including the empty word).

Example

>>> from regexp_learner import suffixes
>>> sorted(suffixes("abcd"))
['', 'abcd', 'bcd', 'cd', 'd']
Parameters:

s (str) – A str instance.

Returns:

The suffixes of s.

Module contents

Top-level package.