RoutingRule#

class scikitplot.corpus.RoutingRule(shape, legs, phrases=(), matcher=None)[source]#

One shape: the words that reveal it and the evidence paths it needs.

Parameters:
shapestr or QueryShape

Shape name, [a-z][a-z0-9_]{0,63}.

legsiterable of LegKind

Paths the shape needs, added by route when available.

phrasesiterable of str, default=()

Words or phrases (lowercase, single spaces) any one of which reveals the shape.

matchercallable or None, default=None

matcher(tokens) -> bool, for what phrases cannot say (a year, a number). The shape is detected if a phrase or the matcher matches.

Raises:
TypeError

If a field has the wrong type.

ValueError

If the shape name or a phrase is malformed, or the rule has neither phrases nor a matcher.

Parameters:
legs: tuple[LegKind, ...][source]#
matcher: Callable[[tuple[str, ...]], bool] | None = None#
matches(tokens)[source]#

Return whether the query, as query_tokens, has this shape.

Raises:
TypeError

If matcher returns something other than a bool.

Parameters:

tokens (tuple[str, ...])

Return type:

bool

phrases: tuple[str, ...] = ()#
shape: str[source]#