Skip to main content

pyprocessors_metadata_from_categories

license tests codecov docs version PyPI - Python Version

Turn the categories carried by a document into a metadata value.

How it works

For every input document the processor converts its categories into a metadata entry and then clears the categories. Conversion happens systematically at both levels:

  • Document level — the document's categories are turned into document.metadata[metadata_name], then document.categories is cleared.
  • Segment level — the same conversion is applied to each sentence: its categories become sentence.metadata[metadata_name], then the sentence's categories are cleared.

For a given set of categories, only those whose score is greater than or equal to multi_label_threshold are kept, and the resulting metadata value is:

  • None (the metadata key is removed) when no category passes the threshold,
  • a single value when exactly one category passes,
  • a list of values when several categories pass.

Parameters

Parameter Default Description
metadata_name None Name of the generated metadata key.
multi_label_threshold 0.0 Only categories with a score greater than or equal to this value are kept.

Installation

You can simply pip install pyprocessors_metadata_from_categories.

Developing

Pre-requesites

You will need to install uv (for managing the virtual environment and running tests):

pip install uv

Clone the repository:

git clone https://github.com/oterrier/pyprocessors_metadata_from_categories

Running the test suite

You can run the full test suite with:

uv run pytest

Linting

uv run ruff check .
uv run ruff format --check .

Building the documentation

You can build the HTML documentation with:

uv run --extra docs sphinx-build docs docs/_build

The built documentation is available at docs/_build/index.html.

SBOM & vulnerability check

Install the SBOM dependencies:

uv sync --extra sbom

Generate a CycloneDX SBOM from the current environment:

uv run cyclonedx-py environment -o sbom.cdx.json --output-format json

Audit dependencies for known vulnerabilities:

uv run pip-audit --format json --output audit-report.json

To fail on any known vulnerability (useful in CI):

uv run pip-audit --strict

Download files

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

Source Distribution

Built Distribution

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

File details

Details for the file pyprocessors_metadata_from_categories-1.6.5.tar.gz.

File metadata

  • Download URL: pyprocessors_metadata_from_categories-1.6.5.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyprocessors_metadata_from_categories-1.6.5.tar.gz
Algorithm Hash digest
SHA256 33e089c098c79e9d6d7963c249b92930e07a71c1a3107b88afdc8309186a5edf
MD5 a456a9d97b559395457476b2ad51338b
BLAKE2b-256 1bd4e987619a781b896b784cc25027530fbb12ccd72ccdd168797086af11d799

See more details on using hashes here.

File details

Details for the file pyprocessors_metadata_from_categories-1.6.5-py3-none-any.whl.

File metadata

  • Download URL: pyprocessors_metadata_from_categories-1.6.5-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyprocessors_metadata_from_categories-1.6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 149f49df5f4227a7404be7f5d8a10cd4fd6d601778dafc6a734b57a2badf2331
MD5 d00edc65d6a5e85c13edab3b77c52b36
BLAKE2b-256 f26928cedb2fcb960186ec581796817ccb500058f8219726034693ce1b403d27

See more details on using hashes here.

Release history Release notifications | RSS feed

1.6.7

2 files

This release

1.6.5 This release

2 files

1.6.4

2 files

1.6.3

2 files

1.6.1

2 files

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