Process-Sanskrit
Process-Sanskrit is an open-source library for automatic Sanskrit text annotation and inflected dictionary search.
The library has two main use cases:
- Dictionary search: multi dictionary lookup with grammatical annotation for words exactly as they are written in texts: in any transliteration format, inflected, compounded and with sandhi.
- Automatic Text Annotation: generate automatically version of Sanskrit texts without sandhi and with split compounds, with grammatical annotations and dictionary entries for each word.
The architecture of the library is based on a cascading approach to Sanskrit text analysis, as described in our NAACL 2025 paper: Accessible Sanskrit: A Cascading System for Text Analysis and Dictionary Access.
The library is one of the main components powering up the Sanskrit Voyager backend. It is used for dictionary searches, stemming, and to pre-process texts for the corpus search.
Demo:
The library can be employed live on the Sanskrit Voyager website.
Select a book or paste some text, click on the words and see the library in action!
Or search some inflected and sandhi-ed words in the search bar to get the dictionary entries.
The following is the Quickstart guide. For a more detailed documentation and advanced features refer to the documentation website.
Installation
To install the library use the standard pip install command, then call update-ps-database in the terminal (or process_sanskrit.update_database() from Python) to setup the database.
pip install process-sanskrit
update-ps-database
Binary wheels for Linux (x86-64, aarch64), macOS (x86-64, arm64) and Windows (x86-64) ship the native Rust sandhi splitter, so installing needs no Rust or C++ toolchain. Building from source requires Rust 1.87 or newer and a C++17 compiler.
update-ps-database downloads and setup the database with the dictionaries and the inflection tables (adjusted from CLS inflect
) in the resources folder (150 mb download, 583 mb uncompressed, released with Creative Commons NC license).
import process_sanskrit
process_sanskrit.update_database() # returns the path of the ready database
## if inside jupyter or colab use:
!pip install process-sanskrit
!update-ps-database
only transliterate works without the database!
Process Function:
The core of the library is the process function, that accepts text in Sanskrit as input and executes an entire text processing pipeline for the text.
import process-sanskrit as ps
ps.process("pratiprasave")
Process returns a list that contains for each word contained in the text or compounds:
- Word stem: ‘pratiprasava’
- Grammatical tagging: masculine noun/adjective ending in a
- Case (for nouns) or Inflection (for verbs): [('Loc', 'Sg')]
- Inflection table for the word as a list: ['pratiprasavaḥ', 'pratiprasavau', 'pratiprasavāḥ', 'pratiprasavam', 'pratiprasavau', 'pratiprasavān', 'pratiprasavena', 'pratiprasavābhyām', 'pratiprasavaiḥ', 'pratiprasavāya', 'pratiprasavābhyām', 'pratiprasavebhyaḥ', 'pratiprasavāt', 'pratiprasavābhyām', 'pratiprasavebhyaḥ', 'pratiprasavasya', 'pratiprasavayoḥ', 'pratiprasavānām', 'pratiprasave', 'pratiprasavayoḥ', 'pratiprasaveṣu', 'pratiprasava', 'pratiprasavau', 'pratiprasavāḥ']
- Original word: 'pratiprasave’
- Word Components according to the Monnier Williams: (in this case none) 'prati—prasava’
- Dictionary entries in XML format. In the form of a dictionary for all the selected dictionaries: {'mw': {'pratiprasava': ['prati—prasava a See under prati-pra- √ 1. sū.', 'prati-°prasava b m. counter-order, suspension of a general prohibition in a particular case, Śaṃkarācārya ; Kātyāyana-śrauta-sūtra , Scholiast or Commentator; Manvarthamuktāvalī, KullūkaBhaṭṭa's commentary on Manu-smṛti ', ' an exception to an exception, Taittirīya-prātiśākhya , Scholiast or Commentator', ' return to the original state, Yoga-sūtra ']}
Process automatically detects transliteration scheme and transliterate to IAST. If that is problematic, pre-transliterate to IAST first using the transliterate function.
Also, the base version of Process is optimised for single words, - if you have a sentence or book, split by spaces and pass each term to transliterate.
In the online interface it is possible to retrive the entries for the components (in this case 'prati' and 'prasava') by clicking on them. Clicking automatically sends to the dictionary entry of the components.
Dictionary Selection:
The process function returns dictionary entries for the found roots.
By default, only the Monnier Williams dictionary is selected.
In the following example we search for a word that is not in the MW: 'dvandva'. The process function automatically check if any of the dictionaries has it and automatically select it. In this case the word is found in the Macdonnell dictionary.
import process_sanskrit as ps
print(ps.process('dvandva'))
To use more dictionaries, process accepts as optional arguments the dictionary abbreviation. In the following code example we retrieve the entries for the word 'saṃskāra' from the Apte, Cappeller, Grassman, and Edgerton dictionaries.
import process_sanskrit as ps
print(ps.process('saṃskāra', 'ap90', 'cae', 'gra', 'bhs'))
### Available Dictionaries and Abbreviations
Here is the list of all the currently available dictionaries with the abbreviations:
- 'mw': 'Monier-Williams Sanskrit-English Dictionary' ,
- 'ap90': 'Apte Practical Sanskrit-English Dictionary'
- ‘cae': 'Cappeller Sanskrit-English Dictionary'
- 'ddsa': 'Macdonell A Practical Sanskrit Dictionary'
- 'gra': 'Grassmann Wörterbuch zum Rig Veda'
- 'bhs': 'Edgerton Buddhist Hybrid Sanskrit Dictionary'
- 'cped': 'Concise Pali English Dictionary'
All the dictionaries are slightly modified version of the *Cologne Digital Sanskrit Dictionaries*, apart from the [The Concise Pali-English Dictionary By Buddhadatta Mahathera](https://buddhistuniversity.net/content/reference/concise-pali-dictionary). The Pali dictionary was added in to handle words that appears in the late Buddhist authors.
Cologne Digital Sanskrit Dictionaries, version 2.7.286, Cologne University, accessed on February 19, 2025, https://www.sanskrit-lexicon.uni-koeln.de
### Stemming:
The process function can be used just for simple sandhi/compound split and stemming, adding the optional flag: *mode=’roots’*.
```python
import process_sanskrit as ps
print(ps.process('yamaniyamāsanaprāṇāyāmapratyāhāradhāraṇādhyānasamādhayo', mode='roots'))
## output:
## ['yama', 'niyama', 'asana', 'prāṇāyāma', 'pratyāhāra', 'dhāraṇa', 'dhyāna', 'samādhi']
In case of ambiguity the process function does not select between the two (or three) possibilities, but returns all of them.
Lemmas for search and indexing:
With mode='lemmas' the same analysis comes back in a shape that can be used directly as a search-index query. There is one item per word of the input, in order. The parts of a word are all required; the lemmas of a part are alternatives.
import process_sanskrit as ps
print(ps.process('yogaścittavṛttinirodhaḥ upagacchati', mode='lemmas'))
## output:
## [{'word': 'yogaścittavṛttinirodhaḥ', 'parts': [
## {'form': 'yogaḥ', 'lemmas': ['yoga', 'yogas']},
## {'form': 'cittavṛtti', 'lemmas': ['cittavṛtti'], 'members': ['citta', 'vṛtti']},
## {'form': 'nirodhaḥ', 'lemmas': ['nirodha']}]},
## {'word': 'upagacchati', 'parts': [
## {'form': 'upa', 'lemmas': ['upa']},
## {'form': 'gacchati', 'lemmas': ['gam', 'upagam']}]}]
A preverb is a part of its own, so a search for gam finds every preverb compound of it. The part after the preverb also carries upagam, the compound they make as Monier-Williams spells it, which ties the preverb to its verb. A word that cannot be analysed comes back as a part with an empty lemmas list, so the caller can index its surface form instead of a guess. See documentation/lemma-mode.md.
Long texts:
The input is never truncated. A text longer than max_length (100 characters by default) is analysed word by word and the results are combined; mode='lemmas' always works word by word. See documentation/long-input.md.
Transliteration:
The library offers a function to transliterate texts with auto-detection for the transliteration input format. This function is a slight adaptation from Indic-Transliteration Detect.
import process_sanskrit as ps
# Transliteration
print(ps.transliterate("patañjali", "DEVANAGARI")) ## IAST
print(ps.transliterate("pataJjali", "DEVANAGARI")) ## HK format
## same output:
## पतञ्जलि
## In case you need to manually select the input scheme,
## force it using the optional 'input_scheme' flag
## the scheme it's not case sensitive (slp1=SLP1):
print(ps.transliterate('pataYjali', 'tamil', input_scheme='slp1'))
## output: பதஞ்ஜலி
process takes the same optional input_scheme. Auto-detection cannot tell the
ASCII schemes apart on short words, so pass the scheme when you know it:
ps.process("Darma", mode="roots") ## read as HK: ['ḍa', 'ma']
ps.process("Darma", input_scheme="slp1", mode="roots") ## [('dharma', 'dharman')]
Dictionary Search:
The library provides the dict_search function to retrieve dictionary entries.
Pass to the dict_search a list of strings to be searched on and (optionally) a list of dictionary tags.
import process_sanskrit as ps
## unlike the process function, the dict_search wants the input in IAST format.
# example usage for Dictionary lookup
ps.dict_search(['pratiprasava', 'saṃskāra'])
# after a list of entries, optionally add dictionary tags to search in multiple dictionaries.
# search in Edgerton Buddhist Hybrid Sanskrit Dictionary
# and Grassmann Wörterbuch zum Rig Veda:
ps.dict_search(['pratiprasava', 'saṃskāra'], 'gra', 'bhs')
The library automatically handles the fact that the Apte records nominatives instead of un-inflected stems (i.E. yogaḥ instead of yoga).
ProcessBYT5
Experimental function: segments the text with the BYT5 model, then sends each
word to the process function for stemming and grammatical results. The model
needs torch and transformers, which the base package does not install, so
this one feature needs the byt5 extra:
pip install process-sanskrit[byt5]
from process_sanskrit.functions.processBYT5 import processBYT5
processBYT5('śrutam āgamavijñānaṃ tat sāmānyaviṣayam')
Sources:
CLS inflect for the inflection tables: https://github.com/sanskrit-lexicon/csl-inflect
The Sanskrit Heritage morphology of Gérard Huet, for the forms the inflection
tables lack (participles, irregular stems, absolutives, infinitives, adverbs in
-tas): the morphology of the Sanskrit Heritage Dictionary 3.84 (2026-09-30),
© Gérard Huet 1994-2026, distributed under the Lesser General Public Licence for
Linguistic Resources (LGPLLR), from
https://sanskrit.uohyd.ac.in/SKT/xml.html.
It is imported into the heritage_* tables of the database, which remain under
its terms. See documentation/heritage-morphology.md.
The Sanskrit Parser library by Karthik Madathil handles part of the Sandhi Splitting: https://github.com/kmadathil/sanskrit_parser
Since v1.5 a reduced, split-only copy of it is vendored under
process_sanskrit/splitter/ (MIT licensed, and gratefully used). The sandhi
splitting behaviour is unchanged — it is verified split-for-split against the
original. See documentation/sandhi-splitter.md
for what was kept, what was dropped, and why.
The split scorer uses a word2vec model trained on the Digital Corpus of Sanskrit (DCS), also from the Sanskrit Parser project: http://www.sanskrit-linguistics.org/dcs/
The BYT5 model used in the experimental version of the process function is from the https://huggingface.co/buddhist-nlp/byt5-sanskrit discussed in the paper:
One Model is All You Need: ByT5-Sanskrit, a Unified Model for Sanskrit NLP Tasks
Metadata
Release files for process-sanskrit 1.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| process_sanskrit-1.9.0.tar.gz | 24.8 MB | With provenance | Details for process_sanskrit-1.9.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| process_sanskrit-1.9.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for process_sanskrit-1.9.0-cp39-abi3-win_amd64.whl |
| process_sanskrit-1.9.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for process_sanskrit-1.9.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| process_sanskrit-1.9.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details for process_sanskrit-1.9.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| process_sanskrit-1.9.0-cp39-abi3-macosx_11_0_x86_64.whl | CPython 3.9 | abi3 | macOS 11.0+ x86-64 | Details for process_sanskrit-1.9.0-cp39-abi3-macosx_11_0_x86_64.whl |
| process_sanskrit-1.9.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for process_sanskrit-1.9.0-cp39-abi3-macosx_11_0_arm64.whl |
Total release size: 138.4 MB
Release files / process_sanskrit-1.9.0.tar.gz
| Download URL | process_sanskrit-1.9.0.tar.gz |
|---|---|
| Size | 24.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26ff4a391d57d988ce9fc26de1ecbe78af618947daa255bed045ad4ccc89b2e3
|
|
BLAKE2b-256 checksum How to use checksums |
91a9771f545cc1c5df87b1c13f93f7d9f51d102ddf4acb5c3f4bbe2d399dfef4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / process_sanskrit-1.9.0-cp39-abi3-win_amd64.whl
| Download URL | process_sanskrit-1.9.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 22.8 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
d9b7fabc5671f68214b68f98796d518a8ef0c2595b300d816775c3e0dc07b025
|
|
BLAKE2b-256 checksum How to use checksums |
f0dd6cc20638e184a30240f4169754e24ab03eeb91a3f42f60733b0c751af15e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / process_sanskrit-1.9.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | process_sanskrit-1.9.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 22.8 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
26077374ec10efc61b24bdd7b9a91fb7195a45084e1f5401cb60d5164a8d8be3
|
|
BLAKE2b-256 checksum How to use checksums |
e3f99055ba9d5af23ea7fe8c402cd8c79afe36c47f13fa1ea0e87334b219f664
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / process_sanskrit-1.9.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | process_sanskrit-1.9.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 22.7 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
6c64d02858518156d1f75b15c8b3c86e1be6fdfdc5d383859b341aa8668228c4
|
|
BLAKE2b-256 checksum How to use checksums |
bb821f7a628f1d79a722fa01a50ebd11049defae0c66e8ac26a18bd852221de8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / process_sanskrit-1.9.0-cp39-abi3-macosx_11_0_x86_64.whl
| Download URL | process_sanskrit-1.9.0-cp39-abi3-macosx_11_0_x86_64.whl |
|---|---|
| Size | 22.7 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
0a5a74c0475df045b4ab1a1d2ef025d9daabff876e0a4176e02564306b8113ae
|
|
BLAKE2b-256 checksum How to use checksums |
f3a4848eef78aa56932981de7d99851ddd6aeefe53e5b7113d3edeec4dd0b8c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / process_sanskrit-1.9.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | process_sanskrit-1.9.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 22.6 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f849a9e16059426045dbf1178736eda6128a912be1eeceefd91fda297b288860
|
|
BLAKE2b-256 checksum How to use checksums |
95ca1acc38c018d29aec479f1fd25a1574b7ac17caa2e75dc244d0de331f0fef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logSecurity for process-sanskrit 1.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for process_sanskrit-1.9.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.