Upasarga and Pratyaya Module

Overview

The Upasarga and Pratyaya module provides advanced tools for handling Sanskrit word prefixes (Upasarga) and suffixes (Pratyaya). This module is crucial for understanding and generating complex Sanskrit word formations.

Key Functions

1. Add Pratyaya

The add_pratyaya function allows adding suffixes to root words with appropriate linguistic rules:

from sanskrit_grammar.upasarga_pratyaya import add_pratyaya

# Add a कृत् (Krit) pratyaya
modified_word = add_pratyaya("गम्", "अ")
print(modified_word)  # Output: गमा

2. Pratyaya Types

Supported Pratyaya Types: - कृत् (Krit): Verbal derivative suffixes - तद्धित: Nominal derivative suffixes

Example Usage

# Adding different types of pratyayas
verb_form = add_pratyaya("पठ्", "अ", pratyaya_type="कृत्")
noun_form = add_pratyaya("राज", "इक", pratyaya_type="तद्धित")

Error Handling

The function raises ValueError for: - Unrecognized pratyaya types - Invalid pratyaya for a given type

API Reference

add_pratyaya(word: str, pratyaya: str, pratyaya_type: str = 'कृत्')

Add a pratyaya (suffix) to a root word with appropriate rules.

Parameters:
  • word (str) – The root word to modify

  • pratyaya (str) – The suffix to add

  • pratyaya_type (str, optional) – Type of pratyaya, defaults to “कृत्”

Returns:

Modified word with suffix

Return type:

str

Raises:

ValueError – If pratyaya or pratyaya type is not recognized