Ashtadhyayi Simulator API Reference
This page contains the detailed API reference for the Ashtadhyayi Simulator module.
Classes
- class sanskrit_grammar.ashtadhyayi_simulator.PaniniSutras[source]
Bases:
object- __init__()[source]
Initialize the PaniniSutras class with predefined sets of rules. For simplicity, we’ll demonstrate a few Sutras for noun declensions.
- apply_sutra(rule, word)[source]
Apply a specific Paninian sutra on the given word. :param rule: The rule identifier (such as ‘nakara_svara’) :param word: The word on which the rule should be applied :return: The transformed word after applying the rule
- nakara_svara(word)[source]
This rule deals with the transformation of certain consonants like ‘n’ into their appropriate vowel sounds. For demonstration purposes, let’s apply a simple transformation. Example: “न” to “नं” (like “नकार” becoming “नं”).
Methods
- PaniniSutras.apply_sutra(rule, word)[source]
Apply a specific Paninian sutra on the given word. :param rule: The rule identifier (such as ‘nakara_svara’) :param word: The word on which the rule should be applied :return: The transformed word after applying the rule
- PaniniSutras.nakara_svara(word)[source]
This rule deals with the transformation of certain consonants like ‘n’ into their appropriate vowel sounds. For demonstration purposes, let’s apply a simple transformation. Example: “न” to “नं” (like “नकार” becoming “नं”).
Example Usage
# Create an instance of PaniniSutras
panini = PaniniSutras()
# Apply a specific sutra
result = panini.apply_sutra('nakara_svara', 'नकार')
print(result) # Output: नकारं
# Apply vowel transformation
result = panini.apply_sutra('vowel_to_vowel_rule', 'राजा')
print(result) # Output: राजी
# Apply declension
result = panini.apply_declension('देवा')
print(result) # Output: देवां