cursus.core.deps.semantic_matcher

Semantic matching utilities for intelligent dependency resolution.

This module provides algorithms for calculating semantic similarity between dependency names and output names to enable intelligent auto-resolution.

class SemanticMatcher[source]

Bases: object

Semantic similarity matching for dependency resolution.

calculate_similarity(name1, name2)[source]

Calculate semantic similarity between two names.

Parameters:
  • name1 (str) – First name to compare

  • name2 (str) – Second name to compare

Returns:

Similarity score between 0.0 and 1.0

Return type:

float

calculate_similarity_with_aliases(name, output_spec)[source]

Calculate semantic similarity between a name and an output specification, considering both logical_name and all aliases.

Parameters:
  • name (str) – The name to compare (typically the dependency’s logical_name)

  • output_spec (Any) – OutputSpec with logical_name and potential aliases

Returns:

The highest similarity score (0.0 to 1.0) between name and any name in output_spec

Return type:

float

find_best_matches(target_name, candidate_names, threshold=0.5)[source]

Find the best matching names from a list of candidates.

Parameters:
  • target_name (str) – Name to match against

  • candidate_names (List[str]) – List of candidate names

  • threshold (float) – Minimum similarity threshold

Returns:

List of (name, score) tuples sorted by score (highest first)

Return type:

List[Tuple[str, float]]

explain_similarity(name1, name2)[source]

Provide detailed explanation of similarity calculation.

Parameters:
  • name1 (str) – First name to compare

  • name2 (str) – Second name to compare

Returns:

Dictionary with detailed similarity breakdown

Return type:

Dict[str, Any]