Skip to main content

NLP toolkit for annotator polarization research: synthetic datasets, polarized trees, and disagreement metrics

Project description

polartox

NLP toolkit for annotator polarization research. Provides tools for synthetic dataset generation and polarization detection in human annotation studies.

Install

pip install polartox

# with nDFU support (Pavlopoulos & Likas, 2024 -- github.com/ipavlopoulos/ndfu)
pip install "polartox[ndfu]"

Tools

Module Description Status
polartox.datagen Synthetic annotator pool with injected, ground-truth polarization Stable
polartox.trees Polarized Trees detection algorithm Coming soon

polartox.datagen

Builds a pool of annotators with explicit demographic identities and generates annotation datasets where every text independently gets k active dimensions (0–4) that drive its disagreement:

  • k = 0 — no dimension explains anything, a true unimodal negative control
  • k ≥ 1 — a random subset of dimensions is active, each with its own random toxic/civil lean split and a continuous intensity (alpha) controlling how strongly it pulls toward its pole

Identities' rating distributions are built by taking the elementwise product of their active-dimension shapes — signal composes rather than averages away, reaching the full nDFU range instead of collapsing toward the middle.

The generative config is returned alongside the dataset as ground truth, enabling direct validation of detection algorithms.

from polartox.datagen import AnnotatorPool, DEFAULT_DIMENSIONS, DEFAULT_DEPTH_WEIGHTS, DEFAULT_INTENSITY_RANGE

pool = AnnotatorPool(
    dimensions=DEFAULT_DIMENSIONS,
    scale=5,
    intensity_range=DEFAULT_INTENSITY_RANGE,
    depth_weights=DEFAULT_DEPTH_WEIGHTS,
    annotators_per_identity=10,
)

result = pool.generate_dataset(
    n_texts=100,
    n_annotators_per_text=150,
    noise=0.05,
    seed=42,
)
dataset, ground_truth = result
# dataset columns: text_id, annotator_id, <dimensions>, rating
# ground_truth: per-text active_dims, lean (toxic/civil split), and alpha (intensity)

nDFU scoring is provided by the collaborative ndfu package (Pavlopoulos & Likas, 2024) rather than reimplemented here:

from ndfu import dfu, pdf

text_data = dataset[dataset["text_id"] == 0]
hist = pdf(text_data["rating"].tolist(), range(1, pool.scale + 1))
score = dfu(hist)

Full API documentation available on GitHub.

Changelog

See CHANGELOG.md for release history.

Project details


Download files

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

Source Distribution

polartox-0.1.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

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

polartox-0.1.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file polartox-0.1.0.tar.gz.

File metadata

  • Download URL: polartox-0.1.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for polartox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 64d8ba25c09efee94be8a9a75bd0a0a9c38e4c787743de5c809c0bf86824dfb1
MD5 e67ab7cb230d7167399b1d1490ddb894
BLAKE2b-256 ea6ba8f92fed3e3e4bf878a7bf478143b896a60d5b0482903818574445c20ae5

See more details on using hashes here.

File details

Details for the file polartox-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: polartox-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for polartox-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aacaadc7f1ee054cea97bcb4d7fa8c403dfe2ba564dda09db04b4bf1c64ad1b2
MD5 488cc090cb509d3aa3ac6bd57345e405
BLAKE2b-256 9ab2967c698eb3dcb8e2e53de6804f430ff323e3de0c87bde499bb269156e512

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page