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

File metadata

  • Download URL: pyprocessors_metadata_from_categories-1.6.7.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.7.tar.gz
Algorithm Hash digest
SHA256 437ed6f36a990fdd270d3205d3495f3b4b558116680064035d7ed500a34617b6
MD5 b38bd8ee93743002e5d9abddab45ac9d
BLAKE2b-256 c1a9f18a697db926b6fff6b95626fdbf8f8b49a74f0a014c6cef6e2774c98b44

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyprocessors_metadata_from_categories-1.6.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 68b6606c19bdada2b77875bc7a31dbb5e5db804dd4f47c34c4a93e103a79a3f0
MD5 7a62df966391c5cf9aa4cbecc3daa3e2
BLAKE2b-256 c19ba5ff91df51d6f3558d0262b60a63afcd5cd57ccad44abd31e782b679bc21

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.6.7 This release

2 files

1.6.5

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