Skip to main content

Process-Sanskrit

Process-Sanskrit is a python open-source library for automatic Sanskrit text annotation and inflected dictionary search.

The library has two main use cases:

  1. 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.
  2. 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 to setup the database.

pip install process-sanskrit
update-ps-database

or, for the experimental BYT5 model:
pip install process-sanskrit[byt5]
update-ps-database

Everything the core pipeline needs — including sandhi splitting with full statistical (DCS word2vec) scoring — is installed by the base package. There are no extras to remember and nothing pins an old numpy.

Binary release wheels are configured to include the native Rust splitter. Building from source requires Rust 1.87 or newer and a C++17 compiler. Scored differential parity and the local release-mode performance criteria are green. Cross-platform wheel CI and installation tests remain publication gates. Consult the current status, backend selection, and build details in the Rust splitter guide.

Upgrading from 1.0.x? The [gensim] extra is gone. Statistical scoring used to be opt-in, which meant a plain pip install process-sanskrit silently ranked sandhi splits by length and produced noticeably worse results. Scoring is now always on, and gensim is no longer used at all. Just drop the extra: pip install process-sanskrit (not process-sanskrit[gensim]). See documentation/sandhi-splitter.md.

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).

## if inside jupyter or colab use:

!pip install process-sanskrit
!update-ps-database

For the experimental version with byt5:

## if inside jupyter or colab use:

!pip install process-sanskrit[byt5]
!update-ps-database

only transliterate works without the database!

Deployments that keep the database outside the Python package can set PROCESS_SANSKRIT_DB_PATH to the existing SQliteDB.sqlite file. The library opens it read-only; see documentation/database-location.md.

Persistent analysis cache

Expensive sandhi and compound analyses are cached by default in a separate, disk-backed SQLite database. The dictionary database remains read-only. Cached results expire after 90 inactive days by default; set PROCESS_SANSKRIT_CACHE_RETENTION=keep_all to retain the de-duplicated prediction corpus indefinitely, or PROCESS_SANSKRIT_CACHE_ENABLED=false to disable persistence. Individual calls can pass cached=False or cached=True.

See the local cache guide for paths, privacy, retention, web-worker behaviour, and ML-corpus limitations.

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:

  1. Word stem: ‘pratiprasava’
  2. Grammatical tagging: masculine noun/adjective ending in a
  3. Case (for nouns) or Inflection (for verbs): [('Loc', 'Sg')]
  4. 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āḥ']
  5. Original word: 'pratiprasave’
  6. Word Components according to the Monnier Williams: (in this case none) 'prati—prasava’
  7. 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.

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: பதஞ்ஜலி

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 -- preprocess the text with BYT5 then sends it to the process function after for stemming and grammatical results.

!pip install process-sanskrit[byt5]
!update-ps-database

from process_sanskrit.functions import processBYT5
ps.process(‘śrutam āgamavijñānaṃ tat sāmānyaviṣayam’)

Sources:

CLS inflect for the inflection tables: https://github.com/sanskrit-lexicon/csl-inflect

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

Sebastian Nehrdich, Oliver Hellwig, Kurt Keutzer

https://arxiv.org/abs/2409.13920

Metadata

Release files for process-sanskrit 1.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for process-sanskrit 1.5.1
File Size Uploaded
process_sanskrit-1.5.1.tar.gz 24.4 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for process-sanskrit 1.5.1
File
process_sanskrit-1.5.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
process_sanskrit-1.5.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
process_sanskrit-1.5.1-cp39-abi3-macosx_11_0_x86_64.whl CPython 3.9 abi3 macOS 11.0+ x86-64 Details
process_sanskrit-1.5.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details

Total release size: 115.0 MB

Release files / process_sanskrit-1.5.1.tar.gz

Download URL process_sanskrit-1.5.1.tar.gz
Size 24.4 MB
Tags Source
SHA-256 checksum
How to use checksums
3f494925027c872370d6feb21f13b5cac197be9330a11574f8ab2e9d60923f87
BLAKE2b-256 checksum
How to use checksums
bbce9c4ff6a376eb324249371c41028fe60fec039c4737bb4a78b41d3b1dc026
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 14, 2026.

Transparency log

Release files / process_sanskrit-1.5.1-cp39-abi3-win_amd64.whl

Download URL process_sanskrit-1.5.1-cp39-abi3-win_amd64.whl
Size 22.7 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1624199bbd79401928f63dbfb1ca6472cfc28b27f4c36b79fd04ebc24907a37c
BLAKE2b-256 checksum
How to use checksums
7eba037ed0c637b7409f1cca8fa444c9c4e58803728aef2be95fcf620da035be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 14, 2026.

Transparency log

Release files / process_sanskrit-1.5.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL process_sanskrit-1.5.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 22.7 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
2cefd471793c3201332bb7f9f7cfcf373863a3239a11446627c0d861d1b0c422
BLAKE2b-256 checksum
How to use checksums
eee5a3cc9a22822333470a34ef859fdb008ea10259b2b8f2f794f1559ac79c36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 14, 2026.

Transparency log

Release files / process_sanskrit-1.5.1-cp39-abi3-macosx_11_0_x86_64.whl

Download URL process_sanskrit-1.5.1-cp39-abi3-macosx_11_0_x86_64.whl
Size 22.6 MB
Tags CPython 3.9 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
2507db1477a122ce2f394afc30dc40b984f44e55b7ec99e9c8250558027eb8ab
BLAKE2b-256 checksum
How to use checksums
2641baa51c642c02cd269aeefa794141e6eb2f0e2af15765eeb0dac7b9569faf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 14, 2026.

Transparency log

Release files / process_sanskrit-1.5.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL process_sanskrit-1.5.1-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
c1cd868bfc15eed2f9fb31989986c322e6d4931376c45f41bdeec911d00e6c8f
BLAKE2b-256 checksum
How to use checksums
a27be04c0bffb4dc99a920130470a6905f8c8d7225710a1a5cc873aeba250d31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 14, 2026.

Transparency log

Release history Release notifications | RSS feed

1.5.2

6 release files

This release

1.5.1 This release

5 release files

1.1.0

2 release files

1.0.24

2 release files

1.0.23

2 release files

1.0.22

2 release files

1.0.21

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.18

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page