API
This page defines an API reference for the vidyut package.
The tools we used to generate this page are optimized for pure Python modules. But since this package is not pure Python, these tools occasionally have issues when processing our code. Known issues:
Enum members don’t have docstrings.
Special methods (__new__, …) don’t have docstrings.
Function docs don’t have argument types or return types.
Properties and attributes don’t have types.
We will fix these issues as soon as we can. In the meantime, please refer to the extensive examples in Quickstart.
vidyut.cheda
vidyut.cheda segments and tags Sanskrit expressions.
vidyut.kosha
Consumer types
- class vidyut.kosha.Kosha
A compact Sanskrit kosha.
- __contains__(key, /)
Return key in self.
- __new__(**kwargs)
- contains_prefix(prefix)
Return whether the kosha contains at least one key with prefix prefix.
- get_all(key)
Return all entries with the given key.
- class vidyut.kosha.Pada
Morphological information for a Sanskrit word.
For ease of use in Python, all of these fields are defined on a single type.
- dhatu
The verb root.
- is_purvapada
(For nominals) whether this word must not occur as the last member of a compound.
- lakara
(For verbs) the tense-mood.
- lemma
- linga
(For nominals) the gender.
- static make_avyaya(*, pratipadika)
Create a new avyaya (indeclinable).
- static make_subanta(*, pratipadika, linga, vibhakti, vacana)
Create a new subanta (nominal).
- static make_tinanta(*, dhatu, purusha, vacana, lakara, pada_prayoga)
Generic constructor. This is a useful test of our repr representation. TODO: handle creating a word with invalid state, e.g. a tinanta with no dhatu. Create a new tinanta (verb).
- pada_prayoga
- pos
The part-of-speech.
- pratipadika
- purusha
- vacana
- vibhakti
(For nominals) the case.
Builder API
- class vidyut.kosha.Builder
Builder for a Kosha.
Memory usage is linear in the number of unique lemmas.
- finish()
Complete the build process.
If this method is not called, the output data will be invalid.
- insert(key, pada)
Insert the given (key, pada) pair.
Keys must be inserted in lexicographic order. If a key is received out of order, this method will raise an OSError.
vidyut.prakriya
Main types
Main types define the high-level API.
- class vidyut.prakriya.Ashtadhyayi
An interface to the rules of the Ashtadhyayi.
- derive_krdantas(*, dhatu, krt)
Return all possible krdanta prakriyas that can be derived with the given initial conditions.
- derive_subantas(*, pratipadika, linga, vibhakti, vacana)
Return all possible krdanta prakriyas that can be derived with the given initial conditions.
- derive_tinantas(*, dhatu, prayoga, purusha, vacana, lakara, sanadi=Ellipsis)
Return all possible tinanta prakriyas that can be derived with the given initial conditions.
- class vidyut.prakriya.Dhatupatha
Provides an interface to the Dhatupatha.
Output types
Output types define the output format of our API.
Input types
Input types define the input arguments for our API.
- class vidyut.prakriya.Lakara
The lakara to use in the derivation.
- AshirLin = Lakara.AshirLin
- Lan = Lakara.Lan
- Lat = Lakara.Lat
- Let = Lakara.Let
- Lit = Lakara.Lit
- Lot = Lakara.Lot
- Lrn = Lakara.Lrn
- Lrt = Lakara.Lrt
- Lun = Lakara.Lun
- Lut = Lakara.Lut
- VidhiLin = Lakara.VidhiLin
- static from_string(val)
Create an enum value from the given string.
This is an inverse of the __str__ method.
- class vidyut.prakriya.Linga
The linga to use in the derivation.
- Napumsaka = Linga.Napumsaka
- Pum = Linga.Pum
- Stri = Linga.Stri
- static from_string(val)
Create an enum value from the given string.
This is an inverse of the __str__ method.
- class vidyut.prakriya.Prayoga
The prayoga of some tinanta.
- Bhave = Prayoga.Bhave
- Karmani = Prayoga.Karmani
- Kartari = Prayoga.Kartari
- static from_string(val)
Create an enum value from the given string.
This is an inverse of the __str__ method.
- class vidyut.prakriya.Purusha
The person of some tinanta.
- Madhyama = Purusha.Madhyama
- Prathama = Purusha.Prathama
- Uttama = Purusha.Uttama
- static from_string(val)
Create an enum value from the given string.
This is an inverse of the __str__ method.
- class vidyut.prakriya.Sanadi
- Nic = Sanadi.Nic
- San = Sanadi.San
- Yan = Sanadi.Yan
- YanLuk = Sanadi.YanLuk
- static from_string(val)
Create an enum value from the given string.
This is an inverse of the __str__ method.
- class vidyut.prakriya.Vacana
The number of some tinanta or subanta.
- Bahu = Vacana.Bahu
- Dvi = Vacana.Dvi
- Eka = Vacana.Eka
- static from_string(val)
Create an enum value from the given string.
This is an inverse of the __str__ method.
- class vidyut.prakriya.Vibhakti
The case ending of some subanta.
- Caturthi = Vibhakti.Caturthi
- Dvitiya = Vibhakti.Dvitiya
- Panchami = Vibhakti.Panchami
- Prathama = Vibhakti.Prathama
- Sambodhana = Vibhakti.Sambodhana
- Saptami = Vibhakti.Saptami
- Sasthi = Vibhakti.Sasthi
- Trtiya = Vibhakti.Trtiya
- static from_string(val)
Create an enum value from the given string.
This is an inverse of the __str__ method.
vidyut.sandhi
vidyut.sandhi handles sandhi changes between words.
- class vidyut.sandhi.Split
Models a sandhi split.
- first
The first part of the split.
- is_valid
Whether the split is phonetically valid according to some basic heuristics.
- second
The second part of the split.
- class vidyut.sandhi.Splitter
A sandhi splitter.
- static from_csv(path)
Create a sandhi splitter from the given path.
path should be a CSV with columns first, second, and result.
- split_at(text, index)
Return all possible ways to split text at the given index.
The first field in the split is guaranteed to be non-empty.