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.4.tar.gz.

File metadata

  • Download URL: pyprocessors_metadata_from_categories-1.6.4.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.4.tar.gz
Algorithm Hash digest
SHA256 f853067451a6d10c2e77dc94a4b1c8e08a6e9735b52823f71dca0daa4da8ee1e
MD5 c65b23a4b051bf762942136c69516685
BLAKE2b-256 f331dd9b4bafbe3cf60ad86674d068d3131d30e90306c446deb2c2426e8de5e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyprocessors_metadata_from_categories-1.6.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 14db609ec55af8d1a033a44ffc9bfa120e07c5961a2a40c13fcad5cacc4411dd
MD5 b721c475e1fa0a001929579f6cb887c7
BLAKE2b-256 f737157f60e2b0642949cffe94a537c079d53f4e8ee64397835db71ff9652f95

See more details on using hashes here.

Release history Release notifications | RSS feed

1.6.7

2 files

1.6.5

2 files

This release

1.6.4 This release

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