Skip to content

Commit ec55c8d

Browse files
committed
added test replay fixtures for ranking mode 1
1 parent 1c8a4fa commit ec55c8d

42 files changed

Lines changed: 41 additions & 22 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

server/preprocessing/other-scripts/test/mine_cases.R

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ is_nested <- function(a, b) {
2626

2727
# Recompute the Mode-1 per-cluster candidates exactly as create_cluster_labels does.
2828
cluster_candidates <- function(bundle) {
29-
md <- add_heuristic_keyword_fields(bundle$metadata, bundle$stops)
29+
md <- add_heuristic_keyword_fields(backfill_subject_is_heuristic(bundle$metadata), bundle$stops)
3030
md$keywords_rank_cleaned <- md$subject
31-
co <- get_cluster_corpus(bundle$clusters, md, bundle$stops, bundle$taxonomy_separator, heuristic_col = HEUR_MIN2)
31+
co <- get_cluster_corpus(bundle$clusters, md, bundle$stops, bundle$taxonomy_separator, percluster_filter = TRUE)
3232
tdm <- TermDocumentMatrix(co$corpus, control = list(
3333
tokenize = SplitTokenizer, weighting = function(x) weightSMART(x, spec = "ntn"),
3434
bounds = list(local = c(1, Inf)), tolower = TRUE))
3535
tt <- apply(tdm, 2, function(x) { x2 <- sort(x, TRUE); x2[x2 > 0] })
3636
empty <- which(apply(tdm, 2, sum) == 0)
3737
if (length(empty)) {
38-
fb <- get_cluster_corpus(bundle$clusters, md, bundle$stops, bundle$taxonomy_separator, heuristic_col = HEUR_MIN1)$corpus
38+
fb <- get_cluster_corpus(bundle$clusters, md, bundle$stops, bundle$taxonomy_separator, percluster_filter = FALSE)$corpus
3939
tt[empty] <- fill_empty_clusters(fb)[empty]
4040
}
4141

@@ -78,6 +78,10 @@ mine <- function(path) {
7878
}
7979
}
8080

81-
args <- commandArgs(trailingOnly = TRUE)
82-
files <- if (length(args)) args else fixture_files()
83-
for (f in files) mine(f)
81+
# Only mine when run as a script (Rscript test/mine_cases.R ...), not when another
82+
# script sources this file for its helpers (e.g. test/orcid_review_list.R).
83+
if (sys.nframe() == 0) {
84+
args <- commandArgs(trailingOnly = TRUE)
85+
files <- if (length(args)) args else fixture_files()
86+
for (f in files) mine(f)
87+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)