CA: check the parameters a cacheAs file was created with
Until now, a cacheAs file was used whenever it existed. Changing a
parameter and forgetting to delete the file therefore silently returned
an analysis computed with the old parameters. Inferring the parameters
from the cached data frame would not help much: of the 23 parameters
that affect the result, only node, vc, leftContextSize and
rightContextSize are recoverable from it, which leaves out exactly the
ones that are typically tuned between runs, such as minOccur,
topCollocatesLimit, searchHitsSampleLimit, exactFrequencies, stopwords
and threshold.
The parameters are therefore recorded when the file is written, and
compared on the next call. They are collected from the call frame rather
than listed explicitly, so that parameters added later are covered
without having to remember to register them. Also recorded is the API
URL, since reusing one cache file for two KorAP instances is a mistake
worth catching, and, for reference only, the index revision: corpus
updates should not invalidate an analysis that was deliberately kept.
If parameters differ, the analysis is recomputed and the file
overwritten, with a warning naming the differing parameters. That is
preferred over an error: it never returns results that disagree with the
requested parameters, and never breaks a long pipeline. Users who want
to keep an old analysis can pass a different cacheAs file name.
The parameters are stored in an attribute, so the file stays a plain
data frame for anyone reading it with readRDS(), and the attribute is
stripped when loading, so the returned value is the same whether it came
from the cache or not. Cache files written by 1.3.0 carry no attribute
and are used as they are.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Change-Id: Ib21aa93fa3c2bf1cd42dd07dbfcbd2970841a412
diff --git a/man/collocationAnalysis-KorAPConnection-method.Rd b/man/collocationAnalysis-KorAPConnection-method.Rd
index 02c3f03..734a2f6 100644
--- a/man/collocationAnalysis-KorAPConnection-method.Rd
+++ b/man/collocationAnalysis-KorAPConnection-method.Rd
@@ -83,7 +83,14 @@
\item{vcLabel}{optional label override for the current virtual corpus (used internally when named VC collections are expanded)}
-\item{cacheAs}{path to an RDS file for caching the result. If the file already exists, the cached result is loaded and returned immediately without contacting the server. Otherwise the analysis is run normally and the result is saved to the file before returning. Defaults to \code{NULL} (no caching).}
+\item{cacheAs}{path to an RDS file for caching the result. If the file already exists, the cached result is loaded and returned immediately without contacting the server. Otherwise the analysis is run normally and the result is saved to the file before returning. Defaults to \code{NULL} (no caching).
+
+The analysis parameters are stored alongside the result. If they differ from
+those of the current call, the cached result would not be the one that was
+asked for, so it is recomputed and the file overwritten, with a warning
+naming the parameters that differ. Pass a different \code{cacheAs} file name
+to keep an existing analysis. Cache files written by RKorAPClient 1.3.0 do
+not contain the parameters yet and are used as they are.}
\item{...}{more arguments will be passed to \code{\link[=collocationScoreQuery]{collocationScoreQuery()}}}
}