Skip to main content

A spaCy-based Named Entity Recognition (NER) pipeline optimized for legal documents.

Project description

lexar

PyPI version License: MIT

⚖️ Lexar: A Specialised NER Pipeline for Legal Texts

Lexar is an essential tool for legal tech and data science, providing a spaCy-based Named Entity Recognition (NER) pipeline specifically engineered to extract and classify structured legal information. Traditional NLP models often fail to recognise the nuanced and formal language of legal documents, but Lexar's rule-based engine provides reliable extraction across multiple legal domains.

Why Lexar?

  • High Precision: Leverages sophisticated linguistic and regular expression patterns (rules) to achieve high precision on structured legal entities, avoiding the ambiguity of statistical models in this domain.
  • Deep Legal Taxonomy: Recognises and labels over 12 specialised entity types critical to legal analysis.
  • Seamless Integration: Designed as a standard spaCy component, making it easy to integrate into existing NLP or legal technology workflows.

🚀 Installation

Lexar is compatible with Python 3.8+ and uses standard spaCy dependencies.

# 1. Install the Lexar package from PyPI
pip install lexar

# 2. Install the required base spaCy language model
# Lexar uses this model for tokenisation and standard entities (like PERSON, ORG).
python -m spacy download en_core_web_sm

📖 Usage Example
To begin processing, load the custom NLP pipeline using the primary lexar.load() function and apply it to any legal text.

import lexar

# Load the custom legal NLP pipeline
nlp = lexar.load()

# Example text demonstrating multiple entity types defined in the pipeline
text = "The litigant filed Case No. 2025-CV-340 in the Supreme Court of the State of Texas, citing the GDPR. This matter was settled on the 15th day of October, 2025, and involved a Mortgage Deed."

doc = nlp(text)

print("\n--- Detected Legal Entities ---")
print("-" * 55)

# Iterate through all recognised entities in the document
for ent in doc.ents:
    # Lexar extracts both custom legal entities and standard spaCy entities
    print(f"| Label: {ent.label_.ljust(20)} | Text: {ent.text}")

# Expected Output (Illustrative):
# | Label: CASE_ID             | Text: 2025-CV-340
# | Label: COURT_NAME          | Text: Supreme Court
# | Label: JURISDICTION        | Text: State of Texas
# | Label: ACT_STATUTE         | Text: GDPR
# | Label: LEGAL_DATE          | Text: 15th day of October, 2025
# | Label: DEED_TYPE           | Text: Mortgage Deed

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lexar-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lexar-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file lexar-0.1.0.tar.gz.

File metadata

  • Download URL: lexar-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for lexar-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f55514d3e96157ca055ac4c17103b58fa3be15778f643540e1a10323fa7f35d0
MD5 47898eecba835408c2cd7058fe0fa144
BLAKE2b-256 41b7076ba6c84c215ca8306da374f5ed09eac90bb75f193c902af7a4b7903263

See more details on using hashes here.

File details

Details for the file lexar-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lexar-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for lexar-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ded8740d4e4cd051f8e990415da958edec1d340dd6d75dbcec590a1a8f26d44d
MD5 5f0e75b30ac13eacbb4979330c96311f
BLAKE2b-256 bfadb1fa1c9e0268b4128448ae19a2ec3f03962907ea62d21d982118a0c553b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page