Key Takeaways
- Visual Judgments (VJ) convert dense court rulings into interactive story graphs using NLP and Neo4j.
- Splitting judgments into thematic sub-stories, then recombining them, was key to making graphs readable.
- VJ's initial graph construction was deliberately manual to expose domain-specific NLP failures before automating.
In Part 1 of this series, we established the universal problem — knowledge-intensive domains drowning in unstructured narrative text — and grounded it in the Indian legal system, where a 64-million-case backlog and hundred-page judgments make the need for visual narrative tools urgent and concrete.
Here in Part 2, we'll walk through the methodology behind Visual Judgments (VJ), a system that combines natural language processing with graph database technology to transform dense judicial texts into structured, navigable story graphs.
While the implementation targets Indian Supreme Court rulings, the pipeline architecture and design principles generalize to any domain where complex narratives must be extracted from unstructured prose.
Starting With a Single Judgement
VJ's first phase focused deliberately on one document: Criminal Appeal No. 1785 of 2011, a Supreme Court of India ruling decided on April 18, 2018.
The case — classified under IPC 302/149 (murder in furtherance of common object), IPC 148 (rioting with deadly weapon) and Section 3(2)(5) of the SC/ST Act, 1989 — involved two appellants versus the State of Madhya Pradesh. Eleven accused were originally charged; five were booked under the murder sections leading to life imprisonment and six under the SC/ST Act leading to a year of imprisonment. The trial court later discharged the six SC/ST Act accused after the post-mortem report attributed death to a knife wound in the chest, ruling out other forms of injury as the cause.
The case was selected precisely because it embodied worst-case complexity: multiple accused with overlapping and inconsistent name references, conflicting witness statements across three prime witnesses, a chain of appeals through hierarchical courts and a final ruling that overturned prior convictions by exposing discrepancies in the prosecution's case. The principle is transferable: when building a narrative extraction pipeline for any domain, start with a document representative of worst-case complexity.
Related Article: From Text Overload to Visual Clarity: Why Unstructured Narratives Need Computational Story Graphs
The NLP Preprocessing Pipeline
The judgement was sourced as a PDF from a public repository of Supreme Court decisions and converted to plain text using Python 3. From there, the pipeline applied a sequence of NLP operations using open-source libraries — NLTK and spaCy — that required careful adaptation for legal prose.
Sentence tokenization decomposed the judgement into individual sentences, each stored as a discrete string. The output — a Python list where every sentence was one element — preserved the granularity needed to map specific actions to specific actors.
Word tokenization then split each sentence into constituent terms, producing a list of lists where each inner list represented the words of one sentence.
Part-of-speech tagging was performed using the Brill tagger from the NLTK package — a transformation-based learning method that guesses the tag of each word, then iteratively corrects mistakes. The tagged output was organized into a Pandas data frame where each row represented a sentence and each cell contained a word-tag tuple (e.g., appeals, NNS, directed, VBN, Sanjay, NNP). Only noun phrases, verb phrases, adjectives and cardinals were retained, producing a sparse but analytically rich data frame of subject-verb-object triplets.
Word cloud generation provided a complementary frequency-based view, rapidly identifying domain-critical vocabulary — terms like "victim," "accused," "appellant," "FIR," "conviction" and "evidence." Both high-frequency and low frequency terms received attention, since rare words in legal text often carry disproportionate evidentiary significance.
Why Neo4j and Graph Databases
The natural structure of a crime narrative is a network: people connected by actions, events linked in sequence, evidence tied to outcomes. Relational databases can store this, but they impose a tabular schema that obscures the very relationships the system is designed to reveal.
Many-to-many relationships — eleven accused connected to one victim through different weapons and different charges — require intermediary join tables and nested SQL that adds computational cost and operational complexity. Neo4j, an open-source distributed graph database, represents data as nodes connected by directed edges, with properties attached to both. This maps directly onto narrative structure: a person is a node, an action is a directed edge, a weapon or location is a property.
Neo4j uses the Cypher query language — purpose-built for creating, reading, updating and deleting graph elements — and supports integration with Python through dedicated driver libraries including the Neo4j module, Py2neo and the Neo module.
The property graph model proved critical. Named entities — persons, locations, occasions — are stored as nodes, while the actions connecting them (verbs, adjectives, relationships) become labeled directed edges. This encoding preserves directionality, essential for representing chronological event sequences, and supports traversal queries that execute in milliseconds regardless of data volume.
Related Article: The Architecture of the Agentic Enterprise: Semantics, Governance & Safe Autonomy
The Aggregation-Disaggregation Strategy
The most consequential design decision was architectural. Early attempts to generate a single, unified graph of the entire judgement produced results that were visually unintelligible.
Using spaCy to split the corpus into sentences, identify part-of-speech configurations and extract subject-object relationships yielded a disconnected, incoherent graphical story — a dense web of nodes with overlapping labels that communicated nothing. The solution was what the team termed an "aggregation-disaggregation strategy." Rather than building one monolithic graph, the judgement narrative was decomposed into four thematic sub-stories, each constructed independently and later aggregated into a unified chronological flow:
The overview story mapped all participants — the victim (Sanjay Sorle), eleven accused with their IPC charges, prime witnesses (Amit, Savitri Bai, Ganesh Prasad), the medical examiner (Dr. Nilay Jain) and the presiding judge.
The victim story traced events from the wedding at Bharveli village through the assault, FIR filing and death.
The appellant story tracked the two individuals who appealed to the Supreme Court.
The judge's story captured the reasoning chain and case citations used to establish precedent.
Each sub-story was built in Neo4j using manually authored Cypher queries. Individual instances — small, self-contained graphs representing a single fact (e.g., Sanjay Sorle → DECLARED → Dead) — were created first, connected into larger sub-graphs and finally composed into the complete narrative.
This architectural pattern is the most portable element of the system: in healthcare, sub-stories might be patient history, treatment timeline, adverse events and outcome; in financial compliance, transaction sequence, communication chain, regulatory triggers and findings.
Why the First Phase Was Manual
The subject-verb-object relationships were identified by a human reader. The Cypher queries were handwritten. This was deliberate.
The manual phase served as a knowledge-building exercise: it revealed that the Brill tagger misclassified "gupti" (a concealed dagger) as a proper noun, exposed entity resolution failures around "Shiv" versus "Shiv Kumar" and "Chokhu @ Sudhanshu" versus "Dablu @ Sudhanshu" and demonstrated that POS tagging calibration varies from judgement to judgement because documentation formats are not standardized across Indian courts.
These are not bugs to be patched; they are signals that production-grade narrative extraction in any domain requires purpose-built components that no general-purpose NLP library provides out of the box.
Related Article: AI-Assisted vs. Human-Curated Metadata: The Hybrid Approach That Actually Scales
What the Pipeline Produces
The output — a set of directed, property-enriched sub-graphs navigable in Neo4j — represents something that has not previously existed in Indian legal analytics: a structured, graphical encoding of a judicial narrative that preserves the relationships between actors, actions, evidence and outcomes, and that can be queried, traversed and visually inspected.
In Part 3, we examine what these graphs reveal, what they expose about the case that text alone obscured and what the path forward looks like for scaling this approach from one judgement to thousands.
Next: Part 3 — From Proof of Concept to Production: Results, Domain Challenges, and the Automation Roadmap
Learn how you can join our contributor community.