verb module

class inflex.verb.Verb[source]

Bases: inflex.term.Term

Class for detecting and converting to verb forms.

__init__(term: str)[source]

Creates a Verb instance with detection and conversion methods.

Examples

>>> verb = Verb("fly")
>>> verb.singular()
'flies'
>>> verb.past()
'flew'
>>> verb.past_part()
'flying'
>>> verb.pres_part()
'flown'
>>> verb.is_plural()
True

Note

Capitalisation and whitespace will be preserved between input term and generated output.

Parameters

term (str) – Input word or collocation.

is_verb() → bool[source]

Returns True only if this verb is instantiated via Verb(term).

Returns

Returns True only if this verb is instantiated via Verb(term).

Return type

bool

is_singular() → bool[source]

Detect whether this verb is in singular form.

Returns

True if this verb is deemed singular.

Return type

bool

is_plural() → bool[source]

Detect whether this verb is in plural form.

Returns

True if this verb is deemed plural.

Return type

bool

singular(person: int = 0) → str[source]

Returns this verb’s singular form.

Parameters

person (Optional[int], optional) – Represents the grammatical “person” (1st, 2nd, 3rd). Defaults to 0.

Returns

This verb’s singular form.

Return type

str

plural(person: int = 0) → str[source]

Returns this verb’s plural form.

Parameters

person (Optional[int], optional) – Represents the grammatical “person” (1st, 2nd, 3rd). Defaults to 0.

Returns

This verb’s plural form.

Return type

str

lemma() → str[source]

Return this object’s lemma form.

Examples

>>> Verb('eating').lemma()
'eat'
Returns

This object’s lemma form.

Return type

str

as_regex() → Pattern[str][source]

Returns a re.Pattern which case-insensitively matches any inflected form of the verb.

Returns

Compiled regex object which case-insensitively matches any inflected form

of the verb.

Return type

re.Pattern

Examples

>>> Verb('eat').as_regex()
re.compile('eats|eating|eaten|eat|ate', re.IGNORECASE)
static split_prefix(term: str) → Tuple[str, str][source]

Split the prefix from the term.

Examples

>>> Verb.split_prefix("unbind")
("un", "bind")
>>> Verb.split_prefix("mistake")
("mis", "take")
>>> Verb.split_prefix("reappear")
("re", "appear")
>>> Verb.split_prefix("use")
("", "use")
Parameters

term (str) – The input word to potentially split a prefix from.

Returns

The first string is the prefix, the second string is the remainder.

If the input does not have a prefix to split, then the first string is empty, while the second string is the full input term.

Return type

Tuple[str, str]

static get_subterm(term: str) → Tuple[str, str][source]

Extract last sub-section (split by ‘-’) of the first word.

Examples

>>> Verb.get_subterm("aaa-bbb ccc")
('bbb', 'aaa-{} ccc')
Parameters

term (str) – The input word to potentially split the subterm from.

Returns

The first string is the format string, e.g. “aaa-{} ccc”, while

the second string is the last sub-section, e.g. “bbb”.

Return type

Tuple[str, str]

past() → str[source]

Returns this Verb’s past form.

Examples

>>> verb = Verb("fly")
>>> verb.past()
"flew"
Returns

This Verb’s past form.

Return type

str

pres_part() → str[source]

Returns this Verb’s present participle form.

Examples

>>> verb = Verb("fly")
>>> verb.pres_part()
"flying"
Returns

This Verb’s present participle form.

Return type

str

past_part() → str[source]

Returns this Verb’s past participle form.

Examples

>>> verb = Verb("fly")
>>> verb.pres_part()
"flown"
Returns

This Verb’s past participle form.

Return type

str

is_past() → bool[source]

Detect whether this Verb is in past form.

Returns

True if this Verb is deemed past.

Return type

bool

is_pres_part() → bool[source]

Detect whether this Verb is in present participle form.

Returns

True if this Verb is deemed present participle.

Return type

bool

is_past_part() → bool[source]

Detect whether this Verb is in past participle form.

Returns

True if this Verb is deemed past participle.

Return type

bool

classical() → inflex.term.Term

Returns an object always inflecting in the classical/unassimilated manner.

Examples

>>> Noun('cow').plural()
'cows'
>>> Noun('cow').unassimilated().plural()
'kine'

Note

Identical to unassimilated().

Returns

A Term object, or a subclass thereof.

Return type

Term

indefinite(count: Optional[int] = 1) → str[source]

Return the singular if count == 1, and the plural otherwise.

Examples

>>> verb = Verb("fly")
>>> verb.indefinite(count = 1)
'flies'
>>> verb.indefinite(count = 3)
'fly'
Parameters

count (Optional[int], optional) – The number of objects on which this verb applies. Defaults to 1.

Returns

The singular if count == 1, and the plural otherwise.

Return type

str

is_adj() → bool

Returns True only if this object is instantiated via Adjective(term).

Returns

Returns True only if this object is instantiated via Adjective(term).

Return type

bool

is_noun() → bool

Returns True only if this object is instantiated via Noun(term).

Returns

Returns True only if this object is instantiated via Noun(term).

Return type

bool

unassimilated() → inflex.term.Term

Returns an object always inflecting in the classical/unassimilated manner.

Examples

>>> Noun('cow').plural()
'cows'
>>> Noun('cow').unassimilated().plural()
'kine'

Note

Identical to classical().

Returns

A Term object, or a subclass thereof.

Return type

Term