Metadata-Version: 2.4
Name: docdsl
Version: 0.0.2
Summary: A domain-specific language (DSL) for building readable text extraction rules.
Author-email: Shine Jayakumar <shinejayakumar@yahoo.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/shine-jayakumar/docdsl
Project-URL: Repository, https://github.com/shine-jayakumar/docdsl
Project-URL: Documentation, https://github.com/shine-jayakumar/docdsl/blob/master/Documentation.md
Project-URL: Issues, https://github.com/shine-jayakumar/docdsl/issues
Keywords: dsl,regex,parser,text-extraction,pattern-matching,textx
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Text Processing
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: textX<5,>=4.4
Dynamic: license-file

# DocDSL

![Version](https://img.shields.io/static/v1?label=version&message=v.0.0.1&color=blue)
![License](https://img.shields.io/static/v1?label=license&message=MIT&color=green)
![Status](https://img.shields.io/badge/status-alpha-yellow.svg)
![Open Source](https://img.shields.io/static/v1?label=OpenSource&message=Yes&color=brightgreen)
![GitHub issues](https://img.shields.io/github/issues/shine-jayakumar/docdsl)
![Last Commit](https://img.shields.io/github/last-commit/shine-jayakumar/docdsl)


A declarative DSL for extracting structured information from OCR output, PDFs, reports, and other semi-structured documents.

Instead of writing large, difficult-to-maintain regular expressions, **DocDSL** lets you describe **what** to extract using a simple, readable language while keeping extraction rules separate from your application code.

---

# Installation

```bash
pip install docdsl
```

---
# Quick Start

```python
from docdsl import DSLTranslator, Entity

# Define reusable entities
NAME = Entity(
    name="NAME",
    pattern=r"[A-Za-z ,.'-]+"
)

POSTCODE = Entity(
    name="POSTCODE",
    pattern=r"[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}"
)

# Create the translator
translator = DSLTranslator(
    entities=[
        NAME,
        POSTCODE,
    ]
)

# Describe what to extract
dsl = """
FIND "Name:";
SKIP UNTIL NEWLINE;
CAPTURE TARGET [@NAME];
"""

# Generate the regular expression
pattern = translator.translate(dsl)

print(pattern)
```
---

# Features

- Declarative, English-like extraction language
- Reusable named entities
- Readable extraction rules
- Conditional extraction using `IF`
- Multi-line capture
- Capture between delimiters
- Built-in helper tokens
- Friendly syntax and validation errors
- Exact error locations with line and column information

---

# Documentation

For the complete language reference, see **DSL_REFERENCE.md**.

The reference includes:

- Complete command reference
- DSL syntax
- Built-in helper tokens
- Conditional statements
- Examples
- Best practices
- Exception reference

---

# Requirements

- Python 3.11+

---

# Contributing

Contributions, bug reports and feature requests are welcome.

If you discover a bug or have an idea for improving **DocDSL**, please open an issue or submit a pull request.

---

# License

Released under the MIT License.
