Skip to main content

Python module provides functions to handle and manipulate various aspects of Sanskrit grammar, including word generation, prefixes etc

Project description

This Python module provides functions to handle and manipulate various aspects of Sanskrit grammar, including word generation, prefixes (Upasarga), suffixes (Pratyaya), verb conjugation, noun declension, Sandhi (joining words), Sandhi Vechheda (splitting words), and tense identification. The module is designed to be a foundational tool for working with Sanskrit words and sentences in Python, supporting multiple grammatical operations, and it can be extended further as per specific needs.


Key Functions:

  1. Upasarga (Prefix) and Pratyaya (Suffix) Functions:

    • These functions allow the application of Upasargas (prefixes) and Pratyayas (suffixes) to a root word.
    • The module contains predefined lists of common prefixes and suffixes used in Sanskrit grammar, which can be added to root words to generate valid forms.
  2. Sandhi (Joining Words):

    • The sandhi function applies the rules of Sandhi, which deal with the joining of words in Sanskrit.
    • It simplifies joining two words based on common Sandhi rules (e.g., dropping the last vowel of the first word if it's a vowel and appending the second word).
  3. Sandhi Vechheda (Splitting Words):

    • The sandhi_vechheda function splits joined words based on common Sandhi rules and returns their components.
  4. Verb Conjugation:

    • The module supports simplified verb conjugation in the present and past tenses for first and third-person singular/plural forms.
    • This function uses basic rules of conjugation for Sanskrit verbs and can be extended for more complex verb forms (e.g., future, conditional, etc.).
  5. Noun Declension:

    • The declense_noun function provides simplified declension for a noun based on the nominative case and singular/plural forms.
    • It can be expanded to handle more cases (genitive, accusative, etc.) and genders (masculine, feminine, neuter).
  6. Tense Identification:

    • The identify_tense function helps identify the tense of a verb based on common suffixes associated with different tenses.
    • It currently recognizes verbs in the present and past tenses.
  7. Word Generation:

    • The generate_sanskrit_word function demonstrates how to generate a valid Sanskrit word by applying both a prefix (Upasarga) and suffix (Pratyaya) to a given root word.

Example Usage:

The following are a few examples demonstrating how to use the module:

import sanskrit_grammar

# Apply Upasarga (prefix) to a root word
print(sanskrit_grammar.apply_upasarga("धार", "प्र"))  
# Output: प्रधार

# Apply Pratyaya (suffix) to a root word
print(sanskrit_grammar.apply_pratyaya("धार", "-त्र"))
# Output: धारत्र

# Conjugate verb in present tense, 3rd person, plural
print(sanskrit_grammar.conjugate_verb("गच्छ", "present", "3rd", "plural"))
# Output: गच्छन्ति

# Generate a word by applying Upasarga and Pratyaya to a root word
print(sanskrit_grammar.generate_sanskrit_word("धार", "प्र", "-त्र"))
# Output: प्रधारत्र

Features:

  • Modularity: Each function in the module is independent, allowing users to pick and use only the functions they need.
  • Extendability: The module is designed to be extended. You can add more complex conjugation rules, declension types, or Sandhi handling as necessary.
  • Sanskrit Grammar Rules: Includes a simplified version of the complex rules for Sandhi, verb conjugation, and noun declension.

Use Cases:

  • Sanskrit NLP Projects: This module can be used in projects that involve processing Sanskrit text, such as building an NLP pipeline or generating words using grammatical rules.
  • Learning Aid: A useful tool for Sanskrit learners to understand and generate conjugated verbs, declined nouns, and apply grammatical rules to words.
  • Sanskrit-based Applications: It can serve as a backend for Sanskrit-related applications like text processing, grammar checking, and automated word generation.

Potential Improvements:

  • Extended Conjugation: Handle more verb tenses, moods, and persons (future tense, conditional mood, etc.).
  • Complete Declension: Implement full noun declension for all cases and genders.
  • Advanced Sandhi: Improve Sandhi and Sandhi Vechheda to handle more complex forms, including exceptions and advanced rules.
  • Integrating with NLP tools: The module can be integrated with other NLP libraries for tokenization, morphological analysis, etc.

This module provides a solid foundation for working with Sanskrit grammar, allowing users to perform various grammatical operations programmatically. It is ideal for anyone working with Sanskrit text or developing applications that require grammatical analysis and word generation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sanskrit_grammar-0.2.0.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sanskrit_grammar-0.2.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file sanskrit_grammar-0.2.0.tar.gz.

File metadata

  • Download URL: sanskrit_grammar-0.2.0.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for sanskrit_grammar-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ef9fa395236408802cec7dc78e59c3775e3b353ccb038df864b2cc0c8b21b644
MD5 e81fcebf6287e7dc43eb2a6414183314
BLAKE2b-256 1edaa36486967acb8b7853b5666d590379c9f33a2a4b80d5e6c1ac8a5ddf0f81

See more details on using hashes here.

File details

Details for the file sanskrit_grammar-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sanskrit_grammar-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eef9e292812c10e9c7f2bf1460a1b5e574a5d0ff1e1b7376bcefed9530f7cbff
MD5 c75e653929e8fa233ff8efb5084fd372
BLAKE2b-256 0a76332260630c3fdc9de6942970672de64691a5fd6cc7bc74bde08cad29004a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page