CA: report imputation in multi-VC comparisons when verbose
Imputation was silent, so a result whose top max_delta rows are entirely
presence/absence artifacts looked no different from one built on observed
scores throughout. Pass the connection's verbosity into
add_multi_vc_comparisons() and report how many node/collocate combinations
and label cells were imputed, pointing at the `imputed` column and
queryMissingScores.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Change-Id: I5159483452595f38d09f06411b64a7327814977f
diff --git a/R/collocationAnalysis.R b/R/collocationAnalysis.R
index b5b1ded..b949e2c 100644
--- a/R/collocationAnalysis.R
+++ b/R/collocationAnalysis.R
@@ -256,7 +256,8 @@
multi_result |>
add_multi_vc_comparisons(
- missingScoreQuantile = missingScoreQuantile
+ missingScoreQuantile = missingScoreQuantile,
+ verbose = kco@verbose
)
}
} else {
@@ -574,7 +575,7 @@
sprintf("contains(<%s>, (%s))", span, combined)
}
-add_multi_vc_comparisons <- function(result, missingScoreQuantile = 0.05) {
+add_multi_vc_comparisons <- function(result, missingScoreQuantile = 0.05, verbose = FALSE) {
label <- node <- collocate <- vc <- webUIRequestUrl <- NULL
if (!"label" %in% names(result) || dplyr::n_distinct(result$label) < 2) {
@@ -1288,6 +1289,22 @@
}
comparison$imputed <- comparison$n_imputed > 0L
+ n_imputed_rows <- sum(comparison$imputed)
+ if (n_imputed_rows > 0) {
+ log_info(verbose, sprintf(
+ paste0(
+ "Imputed scores for %d of %d node/collocate combinations (%d of %d label cells) ",
+ "that are not attested in every virtual corpus. Their delta and winner/loser ",
+ "columns reflect presence vs. absence rather than a measured contrast; see the ",
+ "`imputed` column and `queryMissingScores`.\n"
+ ),
+ n_imputed_rows,
+ nrow(comparison),
+ sum(comparison$n_imputed),
+ nrow(comparison) * length(labels)
+ ))
+ }
+
collapse_consensus_url_columns <- function(url_cols) {
if (length(url_cols) == 0) {
return(rep(NA_character_, nrow(comparison)))