Opennyai : An efficient NLP Pipeline for Indian Legal documents
Opennyai is a python library for natural language preprocessing on Indian legal texts.
This library provides unified access to the following 3 pre-trained AI models developed by OpenNyAI which focus on Indian court judgments:
- Named Entity Recognition (NER): GitHub , paper, Huggingface Datasets
- Judgment Structuring using Sentence Rhetorical Roles: GitHub , paper, Huggingface Datasets
- Extractive Summarizer: GitHub
This library is mainly for running the pretrained models on your custom input judgments text. For more details about data and model training, please refer to individual git repo links.
🔧 1. Installation
Using uv (recommended)
Install uv if you haven't already:
curl -LsSf https://astral.sh/uv/install.sh | sh
Create a virtual environment and install opennyai:
uv venv --python 3.13
source .venv/bin/activate
uv pip install opennyai
Using pip
You can also install with pip directly (requires Python >= 3.13):
python -m venv .venv
source .venv/bin/activate
pip install -U opennyai
For GPU support
If you want to utilize spacy with GPU please install Cupy with the appropriate CUDA version:
pip install cupy-cuda12x # For CUDA 12.x
In case of any issue with installation please refer to spacy installation with cupy.
📖 2. Documentation
Please refer to the Documentation for more details.
👩💻 3. Usage
To run the 3 OpenNyAI models on judgment texts of your choice please run following python code
from opennyai import Pipeline
from opennyai.utils import Data
import urllib
# Get court judgment texts on which to run the AI models
text1 = urllib.request.urlopen(
'https://raw.githubusercontent.com/OpenNyAI/Opennyai/master/samples/sample_judgment1.txt').read().decode()
text2 = urllib.request.urlopen(
'https://raw.githubusercontent.com/OpenNyAI/Opennyai/master/samples/sample_judgment2.txt').read().decode()
# you can also load your text files directly into this
texts_to_process = [text1, text2]
# create Data object for data preprocessing before running ML models
data = Data(texts_to_process)
# If you have access to GPU then set this to True else False
use_gpu = True
# Choose which of the AI models you want to run from the 3 models 'NER', 'Rhetorical_Role','Summarizer'. E.g. If just Named Entity is of interest then just select 'NER'
pipeline = Pipeline(components=['NER', 'Rhetorical_Role', 'Summarizer'], use_gpu=use_gpu, verbose=True)
results = pipeline(data)
The output of each model is present in following keys of each element of the output
results[0][
'annotations'] ## shows the result of model at sentence level, each entry will have entities, rhetorical role, and other details
results[0]['summary'] ## shows Summary for each of the Rheorical Role for first judgment text
For more details on usage please refer to the documentation
Google Colab Notebook
| Description | Link |
|---|---|
| Run Inference |
Metadata
Release files for opennyai 0.0.15
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 | |
|---|---|---|---|---|
| opennyai-0.0.15.tar.gz | 903.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opennyai-0.0.15-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.1 MB
Release files / opennyai-0.0.15.tar.gz
| Download URL | opennyai-0.0.15.tar.gz |
|---|---|
| Size | 903.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d20b4cc588e54b7d5b9c11ea76574a9878499128bc7f1bfefced8d2b99473d0
|
|
BLAKE2b-256 checksum How to use checksums |
e8f8fa1e746aa63ab12fb793a06e98d0d97f72f03cf1278b0fb5db222307d649
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / opennyai-0.0.15-py3-none-any.whl
| Download URL | opennyai-0.0.15-py3-none-any.whl |
|---|---|
| Size | 171.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c58109ada3a461a437043635d210624f5276517d77fe9a481d590f623aae71c4
|
|
BLAKE2b-256 checksum How to use checksums |
3ad0ec0934f45361e7d255815d113f5ede946e623fe18157e586b8957f81ebd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for opennyai 0.0.15
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.