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

File metadata

  • Download URL: pyprocessors_metadata_from_categories-1.6.3.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.3.tar.gz
Algorithm Hash digest
SHA256 e09423344ebca46741de74832351ba046ed4b3e9a29c36c351370d9a5b0497fc
MD5 39aeebf5e83a5b0fc184895aed0e24cc
BLAKE2b-256 a016b94604617c4fe305ba4978fdb2503c056bc44cdeec2eeaa5e7d9a03a68d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyprocessors_metadata_from_categories-1.6.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 65542dcda8f84dc81ef0cd1acda029a826533df3c6ee9d2cf01ae089b0d2aaee
MD5 6af699e126e462b89660eee6d8282b7b
BLAKE2b-256 f12ad42674b7d41089e5e2d8c5bcb5388cdf249d1acd26c7421894f9f909c0b7

See more details on using hashes here.

Release history Release notifications | RSS feed

1.6.7

2 files

1.6.5

2 files

1.6.4

2 files

This release

1.6.3 This release

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