vibe.linguistics.base

Abstract base class for language-specific grammar rules.

LanguageRules

Abstract base class for language-specific grammar rules.

Each supported language implements this class to provide: - Grammar transformation rules (pluralize, definite, possessive) - Number-to-word conversion (cardinal, ordinal) - Filter aliases for templates in that language - Tag aliases for the enumerate extension

pluralize

pluralize(word: str, context: Linguistic | None = None, overrides: str | None = None) -> str

Convert a word to its plural form.

Parameters:
  • word (str) –

    The word to pluralize

  • context (Linguistic | None, default: None ) –

    Optional Linguistic context

  • overrides (str | None, default: None ) –

    Optional override string for ad-hoc irregular forms. Format: "singular->plural,singular2->plural2"

make_definite

make_definite(word: str, number: str = 'singular', gender: GrammaticalGender | None = None, context: Linguistic | None = None, overrides: str | None = None) -> str

Convert a word to its definite form.

Parameters:
  • word (str) –

    The word to make definite

  • number (str, default: 'singular' ) –

    "singular" or "plural"

  • gender (GrammaticalGender | None, default: None ) –

    Optional gender hint

  • context (Linguistic | None, default: None ) –

    Optional Linguistic context

  • overrides (str | None, default: None ) –

    Optional override string "word->definite,word2->definite2"

make_possessive

make_possessive(word: str, subject: str | None = None, context: Linguistic | None = None, overrides: str | None = None) -> str

Convert a word to its possessive/genitive form.

Parameters:
  • word (str) –

    The word to make possessive

  • subject (str | None, default: None ) –

    Optional subject to add

  • context (Linguistic | None, default: None ) –

    Optional Linguistic context

  • overrides (str | None, default: None ) –

    Optional override string "word->possessive,word2->possessive2"

make_indefinite

make_indefinite(word: str, gender: GrammaticalGender | None = None, context: Linguistic | None = None, overrides: str | None = None) -> str

Add indefinite article to a word.

Parameters:
  • word (str) –

    The noun to add article to

  • gender (GrammaticalGender | None, default: None ) –

    Optional gender hint

  • context (Linguistic | None, default: None ) –

    Optional Linguistic context

  • overrides (str | None, default: None ) –

    Optional override string "word->indefinite,word2->indefinite2"

Returns:
  • str

    Word with appropriate indefinite article

number_to_cardinal

number_to_cardinal(num: int) -> str

Convert a number to its cardinal word form (e.g., 3 -> 'three').

number_to_ordinal

number_to_ordinal(num: int) -> str

Convert a number to its ordinal word form (e.g., 3 -> 'third').

format_doublet

format_doublet(num: int, unit: str | None = None) -> str

Format a number as a legal doublet: word (digits) [unit].

Default implementation uses cardinal form. Override for locale-specific formatting.

format_conjunction

format_conjunction(conjunction_type: str) -> str

Return the localized conjunction word.

Parameters:
  • conjunction_type (str) –

    "and" or "or"

Returns:
  • str

    Localized conjunction word

uses_oxford_comma

uses_oxford_comma() -> bool

Whether this language uses the Oxford comma in lists.

get_gender_hint

get_gender_hint(word: str) -> GrammaticalGender | None

Attempt to determine grammatical gender from word form.

Override in subclasses that support gender. Returns None if unknown.