Skip to main content

normasbr

MIT licensed Python 3.12 Ruff CI PyPi Latest Release Downloads readthedocs Python

⚠️ ATENÇÃO ⚠️: Biblioteca ainda em estágio muito experimental, e sem garantias de retrocompatibilidade entre as versões.

normasbr é uma biblioteca Python que extrai, segmenta e estrutura normativas brasileiras (leis, decretos, medidas provisórias etc.) a partir de HTML, PDF, DOCX ou TXT, convertendo textos brutos em documentos estruturados (YML), com hierarquia completa de dispositivos (norma > agrupadores > artigos > incisos > alíneas > itens).

O processamento é determinístico, usando heurísticas e expressões regulares baseadas em documentos normativos diversos.

Pipeline

ingerir -> segmentar -> estruturar
  1. Ingestão: normaliza HTML/PDF/DOCX/TXT para um HTML canônico;
  2. Segmentação: extrai blocos de texto e classifica cada segmento (artigo, parágrafo, inciso, ementa, preâmbulo, bloco de alteração etc.);
  3. Estruturação: monta a árvore hierárquica da normativa a partir dos segmentos;

Instalação

A última versão pode ser instalada com o uv:

uv add normasbr # Usando como biblioteca
uv tool install normasbr # Usando como utilitário de linha de comando

Ou diretamente do repositório:

uv pip install git+https://github.com/ipea/normasbr

Exemplo de uso

Biblioteca:

import normasbr

for bruta in normasbr.despachar_ingestao("data/DEL5452.htm"):
    segmentos = normasbr.Segmentador().segmentar(normasbr.extrair_blocos(bruta))
    normas = normasbr.estruturar(segmentos, leniente=True)

print(normasbr.formatar_normativas_yml(normas))

CLI:

normasbr ingerir data/DEL5452.htm
normasbr segmentar data/docs
normasbr estruturar data/docs -o normas.yml
normasbr diff_seg snapshot.jsonl novo.jsonl
normasbr classificar_macrodim normas.yml saida.parquet

Desenvolvimento

make setup   # cria o venv e instala as dependências
make check   # lint (ruff) + testes (pytest)
make format  # formata o código

Referências usadas na modelagem

Nota Ipea

normasbr é desenvolvido por uma equipe de pesquisadores do Instituto de Pesquisa Econômica Aplicada (Ipea).

Metadata

Release files for normasbr 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for normasbr 0.0.2
File Size Uploaded Provenance Actions
normasbr-0.0.2.tar.gz 30.3 kB With provenance Details for normasbr-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for normasbr 0.0.2
File Interpreter ABI Platform Actions
normasbr-0.0.2-py3-none-any.whl Python 3 none any Details for normasbr-0.0.2-py3-none-any.whl

Total release size: 68.7 kB

Release files / normasbr-0.0.2.tar.gz

Download URL normasbr-0.0.2.tar.gz
Size 30.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4aa1969660af24d61e1142328e6a784bd11a6ab63a2e8d52d6565970675104b7
BLAKE2b-256 checksum
How to use checksums
2c0b5766940fd7275f8b85e1004bddb99f3acc3a2a3c889918583bb7cfa0c860
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.

Transparency log

Release files / normasbr-0.0.2-py3-none-any.whl

Download URL normasbr-0.0.2-py3-none-any.whl
Size 38.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c54bbe9586bd54eecb3472154204bd68d3396e8fecf301ddbcdbefe3f936bc14
BLAKE2b-256 checksum
How to use checksums
b877d824321c9bdd079acbdd80ef369baa48060a4d5a52f8add0546eba376df4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.

Transparency log

Security for normasbr 0.0.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for normasbr-0.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page