Example Usage

Quick Reference

Inflex provides three objects, which contain the following most important methods:

Noun

Let’s introduce a running example:

>>> noun = Noun("brother")
  • singular: Return the singular form of this noun.

    >>> noun.singular()
    "brother"
    
  • plural: Return the plural form of this noun.

    >>> noun.plural()
    "brothers"
    
  • lemma: Return the lemma for this noun, identical to singular.

  • is_singular: Return whether this noun is singular.

    >>> noun.is_singular()
    True
    
  • is_plural: Return whether this noun is plural.

    >>> noun.is_plural()
    False
    
  • classical / unassimilated: Return a ClassicalNoun instance, which is a subclass of Noun, but with classical conversions instead.

    >>> noun.classical().plural()
    "brethren"
    
  • as_regex: Return a re.Pattern which matches any inflected form of the word.

    >>> noun.as_regex()
    re.compile('brothers|brother|brethren', re.IGNORECASE)
    
  • indef_article: Return the correct indefinite article (‘a’ or ‘an’) for word.

    >>> noun.indef_article()
    "a"
    
  • indefinite: Prepend ‘a’ or ‘an’ or the number to the correct form of this Noun.

    >>> noun.indefinite(count = 1)
    "a brother"
    >>> noun.indefinite(count = 3)
    '3 brothers'
    
Verb

Let’s introduce a running example:

>>> verb = Verb("fly")
  • singular: Return the singular form of this verb.

    >>> verb.singular()
    "flies"
    
  • plural: Return the plural form of this verb.

    >>> verb.plural()
    "fly"
    
  • past: Return the past form of this verb.

    >>> verb.past()
    "flew"
    
  • pres_part: Return the present participle form of this verb.

    >>> verb.pres_part()
    "flying"
    
  • past_part: Return the past participle form of this verb.

    >>> verb.past_part()
    "flown"
    
  • lemma: Return the lemma for this noun, identical to plural.

  • is_singular: Return whether this verb is in singular form.

    >>> verb.is_singular()
    False
    
  • is_plural: Return whether this verb is in plural form.

    >>> verb.is_plural()
    True
    
  • is_past: Return whether this verb is in past form.

    >>> verb.is_past()
    False
    
  • is_pres_part: Return whether this verb is in present participle form.

    >>> verb.is_pres_part()
    False
    
  • is_past_part: Return whether this verb is in past participle form.

    >>> verb.is_past_part()
    False
    
  • as_regex: Return a re.Pattern which matches any inflected form of the word.

    >>> verb.as_regex()
    re.compile('flying|fly|flown|flies|flew', re.IGNORECASE)
    
Adjective

Let’s introduce a running example:

>>> adj = Adjective("pretty")
  • singular: Return the singular form of this adjective.

    >>> adj.singular()
    "pretty"
    
  • plural: Return the plural form of this adjective.

    >>> adj.plural()
    "pretty"
    
  • comparative: Return the comparative form of this adjective.

    >>> adj.singular()
    "prettier"
    
  • superlative: Return the superlative form of this adjective.

    >>> adj.singular()
    "prettiest"
    
  • is_singular: Return whether this adjective is in singular form.

    >>> adj.is_singular()
    True
    
  • is_plural: Return whether this adjective is in plural form.

    >>> adj.is_singular()
    True
    
  • as_regex: Return a re.Pattern which matches any inflected form of the word. (Only plural and singular)

    >>> adj.as_regex()
    re.compile('pretty', re.IGNORECASE)
    

This quick reference is not exhaustive, but does cover the most important functionality supported by Inflex. Feel free to look at the full API Reference for more detailed information.