schema_linking_eval

compare_query_schema_elements(gold: str, predicted: str, verbose: bool = False) dict

Compares the schema elements (tables and columns) of two SQL queries and calculates precision, recall, and F1 score.

Parameters:
  • gold (str) – The gold standard SQL query.

  • predicted (str) – The predicted SQL query.

  • verbose (bool) – If True, prints detailed comparison results. Defaults to False.

Returns:

A dictionary containing matching, missing, and extra tables and columns, along with precision, recall, and F1 score.

Return type:

dict

mp_compare_query_schema_elements(q_nl_df: pd.DataFrame) dict

Compares query schema elements in a DataFrame using multiprocessing.

Parameters:

q_nl_df (pd.DataFrame) – A DataFrame with ‘query_gold’, ‘query_predicted’, and ‘number’ columns.

Returns:

A dictionary where keys are query numbers and values are comparison results.

Return type:

dict

update_scores_in_existing_results(filename)

Updates precision and F1 scores in an existing Excel file.

Parameters:

filename (str) – The path to the Excel file.

compare_queries()

Compares two example SQL queries using compare_query_schema_elements.