adjective module

class inflex.adjective.Adjective[source]

Bases: inflex.term.Term

Class for detecting and converting to adjective forms.

__init__(term: str)[source]

Creates an Adjective instance with detection and conversion methods.

Examples

>>> adj = Adjective("my")
>>> adj.plural()
'our'
>>> adj = Adjective("pretty")
>>> adj.comparative()
'prettier'
>>> adj.superlative()
'prettiest'

Note

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

Parameters

term (str) – Input word or collocation.

is_adj() bool[source]

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

Returns

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

Return type

bool

is_singular() bool[source]

Detect whether this adjective is in singular form.

Returns

True if this adjective is deemed singular.

Return type

bool

is_plural() bool[source]

Detect whether this adjective is in plural form.

Returns

True if this adjective is deemed plural.

Return type

bool

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

Returns this adjective’s singular form.

Parameters

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

Returns

This adjective’s singular form.

Return type

str

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

Returns this adjective’s plural form.

Parameters

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

Returns

This adjective’s plural form.

Return type

str

lemma() str[source]

Return this object’s lemma form.

Examples

>>> Adjective('pretty').lemma()
'pretty'
Returns

This object’s lemma form.

Return type

str

comparative(only_suffix: bool = False) str[source]

Returns this Adjective’s comparative form.

Parameters

only_suffix (bool, optional) – If True, then only convert by modifying suffix. If False, more can also be prepended as a means of converting to comparative. Defaults to False.

Return type

str

Examples

>>> adj = Adjective("pretty")
>>> adj.comparative()
prettier

Note

“little” or “far” will fail due to having multiple options:
  • little (kid) -> littler (kid)

  • little (food) -> less (food)

and
  • far -> further

  • far -> farther

Fails on e.g. “boring” or “famous” We convert these to “boringer” and “famouser”. In reality they should be “more boring” and “more famous”

Returns

This Adjective’s comparative form.

Return type

str

Parameters

only_suffix (bool) –

superlative(only_suffix: bool = False) str[source]

Returns this Adjective’s superlative form.

Parameters

only_suffix (bool, optional) – If True, then only convert by modifying suffix. If False, most can also be prepended as a means of converting to superlative. Defaults to False.

Return type

str

Examples

>>> adj = Adjective("pretty")
>>> adj.superlative()
prettiest

Note

“little” or “far” will fail due to having multiple options:
  • little (kid) -> littlest (kid)

  • little (food) -> least (food)

and
  • far -> furthest

  • far -> farthest

Fails on e.g. “boring” or “famous” We convert these to “boringest” and “famousest”. In reality they should be “most boring” and “most famous”

Returns

This Adjective’s superlative form.

Return type

str

Parameters

only_suffix (bool) –

as_regex() Pattern[str]

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

Returns

Compiled regex object which case-insensitively matches any inflected form

of the word.

Return type

re.Pattern

Examples

>>> Noun('cherub').as_regex()
re.compile('cherubs|cherubim|cherub', re.IGNORECASE)
>>> Verb('eat').as_regex()
re.compile('eats|eating|eaten|eat|ate', re.IGNORECASE)
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

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

is_verb() bool

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

Returns

Returns True only if this object is instantiated via Verb(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