Giter Club home page Giter Club logo

Opennyai : An efficient NLP Pipeline for Indian Legal documents

Current Release Version PyPI version python version python version Downloads

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
  • Judgment Structuring using Sentence Rhetorical Roles: GitHub , paper
  • 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

To get started using opennyai first create a new python virtual environment using conda:

Supports python 3.8, 3.9, 3.10

conda create -n opennyai python=3.8
conda activate opennyai

Install it using pip by running the following line in your terminal

pip install -U opennyai

For GPU support

If you want to utilize spacy with GPU please install Cupy and cudatoolkit dependency of appropriate version.

conda install cudatoolkit==<your_cuda_version> #### E.g. cudatoolkit==11.2
pip install cupy-cuda<your_cuda_version> ##### E.g. cupy-cuda112

In case of any issue with installation please refer to spacy installation with cupy

Remember you need spacy of 3.2.4 version for models to work perfectly.

📖 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

We encourage you to use the local machine installation of opennyai library instead of Google colab as it works with python 3.8. Since Google colab works with higher versions of python, opennyai installation does not work.

Description Link
Run Inference Open In Colab

Visualization of outputs

We encourage users to use our webapp for visualizing the results for a judgment of your choice.

opennyai's Projects

jb-manager icon jb-manager

Jugalbandi (JB) Manager is a full AI-powered conversational chatbot platform. It's platform agnostic and can serve multiple channels such as WhatsApp or custom web interfaces. It can handle conversations in both text and voice across any language. It comes with Bhashini Speech models out of the box and can failover to Azure. For more info -> ReadMe

jiva-ui icon jiva-ui

JIVA UI is the frontend service that is specific to the JIVA (Judges' Intelligent Virtual Assistant) application which provides the necessary UI for acts and law documents and handles their respective data (the JIVA service APIs).

jugalbandi-old icon jugalbandi-old

This repository is home to several Jugalbandi services and packages for organisations to build and customize on top of them. This repo also includes JIVA service.

legal_docs_redaction icon legal_docs_redaction

For converting the scanned documents to text and doing first level data redaction by masking entities identified. This data needs to be reviewed by humans to make sure all the sensitive information is masked.

opennyai icon opennyai

Opennyai : An efficient NLP Pipeline for Indian Legal documents

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.