-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathranking.ts
More file actions
67 lines (58 loc) · 2.3 KB
/
ranking.ts
File metadata and controls
67 lines (58 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
export type RankingFeatures = {
relevanceScore: number;
venueScore: number;
citationScore: number;
recencyScore: number;
surveyFoundationScore: number;
crossDomainScore: number;
domainProfileBoost: number;
};
export type RankingBreakdown = RankingFeatures & {
finalScore: number;
reasons: string[];
readingLevel: "starter" | "advanced" | "frontier";
};
const clamp = (value: number) => Math.max(0, Math.min(1, value));
export function calculateImportanceScore(features: RankingFeatures): RankingBreakdown {
const normalized: RankingFeatures = {
relevanceScore: clamp(features.relevanceScore),
venueScore: clamp(features.venueScore),
citationScore: clamp(features.citationScore),
recencyScore: clamp(features.recencyScore),
surveyFoundationScore: clamp(features.surveyFoundationScore),
crossDomainScore: clamp(features.crossDomainScore),
domainProfileBoost: clamp(features.domainProfileBoost)
};
const finalScore = Number(
(
100 *
(0.3 * normalized.relevanceScore +
0.22 * normalized.venueScore +
0.16 * normalized.citationScore +
0.1 * normalized.recencyScore +
0.1 * normalized.surveyFoundationScore +
0.07 * normalized.crossDomainScore +
0.05 * normalized.domainProfileBoost)
).toFixed(1)
);
const reasons: string[] = [];
if (normalized.relevanceScore > 0.82) reasons.push("Strong thematic match to the survey query");
if (normalized.venueScore > 0.9) reasons.push("Published in a high-authority venue for the selected domain");
if (normalized.citationScore > 0.75) reasons.push("Strong citation signal relative to peer papers");
if (normalized.recencyScore > 0.8) reasons.push("Recent enough for frontier tracking");
if (normalized.surveyFoundationScore > 0.75) reasons.push("Likely survey, benchmark, or foundational work");
if (normalized.crossDomainScore > 0.65) reasons.push("Covers multiple selected domains");
if (normalized.domainProfileBoost > 0.7) reasons.push("Boosted by built-in domain profile priorities");
const readingLevel =
normalized.surveyFoundationScore > 0.8 || normalized.venueScore > 0.9
? "starter"
: normalized.recencyScore > 0.8
? "frontier"
: "advanced";
return {
...normalized,
finalScore,
reasons,
readingLevel
};
}