src.dackar.similarity.scoreAggregator

Weighted combination of per-dimension similarity scores.

A small, domain-agnostic helper: given a {dimension: weight} mapping, it combines a {dimension: score} mapping into a single scalar, clamped to [0, 1]. Dimensions are arbitrary string labels, so the same aggregator serves any multi-dimensional scoring scheme.

Only the standard library is required.

Classes

WeightedScoreAggregator

Combine per-dimension scores into one total via a weights mapping.

Module Contents

class src.dackar.similarity.scoreAggregator.WeightedScoreAggregator(weights)[source]

Combine per-dimension scores into one total via a weights mapping.

Parameters:

weights (Mapping[str, float]) – {dimension: weight}. Any dimension absent from a given scores mapping contributes 0; any score whose dimension is absent from weights is ignored.

The output of combine() is clamped to [0, 1] regardless of the weight configuration. Without clamping, un-normalized weights (summing to more than 1) would yield totals above 1.0.

weights[source]
combine(scores)[source]

Return the weighted sum of scores, clamped to [0, 1].

Only dimensions present in weights contribute; a weighted dimension missing from scores contributes 0.

Parameters:

scores (Mapping[str, float])

Return type:

float