August 01, 2025

Sanskrit Parsing with Google Colab

1) Goto google colab and create a new notebook.

https://colab.research.google.com/#create=true

2) Copy these 5 lines in a cell and run them using Shift + Enter

!pip install sanskrit_parser
from sanskrit_parser import Parser
parser = Parser(output_encoding='devanagari')
import logging
logging.getLogger('sanskrit_parser').setLevel(logging.WARNING)

3) Copy paste these 4 lines in the next cell and run it.

text = 'तस्मात्समस्त'
splits = parser.split(text, limit=10)
for split in splits:
    print(f'{split}')

You get the output like this...

['तस्मात्', 'समस्त']
['तस्मात्', 'सम्', 'अस्त']

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.