CA: warn when duplicate rows are dropped from multi-VC comparisons

The pivots in add_multi_vc_comparisons() use values_fn = dplyr::first, so
repeated node/collocate/label rows -- as produced when the same collocate is
found at several context positions -- were silently reduced to their first
occurrence. Warn instead, naming mergeDuplicateCollocates() as the way to
combine those rows before comparing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Change-Id: I832ea9a2bc0d28256bba5a37e8b94721809f3a68
diff --git a/R/collocationAnalysis.R b/R/collocationAnalysis.R
index 4f827eb..d185a0c 100644
--- a/R/collocationAnalysis.R
+++ b/R/collocationAnalysis.R
@@ -661,6 +661,25 @@
     score_cols
   )
 
+  # The pivots below keep only the first row per node/collocate/label. Duplicates do occur
+  # legitimately (e.g. the same collocate found at several context positions), but silently
+  # discarding all but one of them would misrepresent the comparison, so say so.
+  comparison_keys <- paste(result$node, result$collocate, result$label, sep = "\r")
+  duplicate_keys <- unique(comparison_keys[duplicated(comparison_keys)])
+  if (length(duplicate_keys) > 0) {
+    warning(
+      sprintf(
+        paste0(
+          "%d node/collocate/label combination(s) occur more than once; only the first row ",
+          "of each is used for the multi-VC comparison columns. Consider ",
+          "mergeDuplicateCollocates() to combine context positions before comparing."
+        ),
+        length(duplicate_keys)
+      ),
+      call. = FALSE
+    )
+  }
+
   comparison <- result |>
     dplyr::select(node, collocate, label, dplyr::all_of(score_cols)) |>
     tidyr::pivot_wider(