primus.scores.SubjectSpanOverlapScore module

class primus.scores.SubjectSpanOverlapScore.SubjectSpanOverlapScore(scorecard_name=None, score_name=None, findings: List[dict] | None = None, files_scanned: List[str] | None = None, findings_command: str | None = None, source_root: str | None = None, **kwargs)

Bases: Score

Programmatic detector that scores Items when a finding matches both metadata.subjectKey and overlapping source-file spans.

Initialize the Score instance with the given parameters.

Parameters

**parametersdict

Arbitrary keyword arguments that are used to initialize the Parameters instance.

Raises

PydanticValidationError

If the provided parameters do not pass validation.

__init__(scorecard_name=None, score_name=None, findings: List[dict] | None = None, files_scanned: List[str] | None = None, findings_command: str | None = None, source_root: str | None = None, **kwargs)

Initialize the Score instance with the given parameters.

Parameters

**parametersdict

Arbitrary keyword arguments that are used to initialize the Parameters instance.

Raises

PydanticValidationError

If the provided parameters do not pass validation.

async classmethod create(**parameters)

Async factory used by Scorecard when loading YAML/API configurations.

load_context(context=None)
async predict(model_input: ScoreInput, **_kwargs) → Result

Make predictions on the input data.

Parameters

contextAny

Context for the prediction

model_inputScore.Input

The input data for making predictions.

Returns

Union[Score.Result, List[Score.Result]]

Either a single Score.Result or a list of Score.Results

predict_validation()

Predict on the validation set.

This method should be implemented by subclasses to provide the prediction logic on the validation set.

register_model()

Register the model with the model registry.

save_model()

Save the model to the model registry.