riksdagsmonitor 0.8.15 → 0.8.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/lib/dashboards/coalition-dashboard.d.ts.map +1 -1
- package/dist/lib/dashboards/coalition-dashboard.js +25 -9
- package/dist/lib/dashboards/coalition-dashboard.js.map +1 -1
- package/dist/lib/dashboards/coalition-loader.d.ts.map +1 -1
- package/dist/lib/dashboards/coalition-loader.js +68 -32
- package/dist/lib/dashboards/coalition-loader.js.map +1 -1
- package/dist/lib/shared/chart-factory.d.ts +9 -2
- package/dist/lib/shared/chart-factory.d.ts.map +1 -1
- package/dist/lib/shared/chart-factory.js +9 -2
- package/dist/lib/shared/chart-factory.js.map +1 -1
- package/dist/lib/shared/theme.d.ts +1 -18
- package/dist/lib/shared/theme.d.ts.map +1 -1
- package/dist/lib/shared/theme.js +1 -18
- package/dist/lib/shared/theme.js.map +1 -1
- package/dist/scripts/analysis-reader.d.ts +2 -1
- package/dist/scripts/analysis-reader.d.ts.map +1 -1
- package/dist/scripts/analysis-reader.js.map +1 -1
- package/dist/scripts/data-transformers/content-generators/index.d.ts +32 -4
- package/dist/scripts/data-transformers/content-generators/index.d.ts.map +1 -1
- package/dist/scripts/data-transformers/content-generators/index.js +4 -2
- package/dist/scripts/data-transformers/content-generators/index.js.map +1 -1
- package/dist/scripts/data-transformers/content-generators/shared.d.ts +44 -2
- package/dist/scripts/data-transformers/content-generators/shared.d.ts.map +1 -1
- package/dist/scripts/data-transformers/content-generators/shared.js +9 -3
- package/dist/scripts/data-transformers/content-generators/shared.js.map +1 -1
- package/dist/scripts/generate-news-enhanced/config.d.ts +5 -4
- package/dist/scripts/generate-news-enhanced/config.d.ts.map +1 -1
- package/dist/scripts/generate-news-enhanced/config.js +3 -3
- package/dist/scripts/generate-news-enhanced/config.js.map +1 -1
- package/dist/scripts/generate-news-enhanced/generators.d.ts.map +1 -1
- package/dist/scripts/generate-news-enhanced/generators.js +38 -15
- package/dist/scripts/generate-news-enhanced/generators.js.map +1 -1
- package/dist/scripts/generate-news-enhanced/helpers.d.ts +1 -2
- package/dist/scripts/generate-news-enhanced/helpers.d.ts.map +1 -1
- package/dist/scripts/generate-news-enhanced/helpers.js +31 -1
- package/dist/scripts/generate-news-enhanced/helpers.js.map +1 -1
- package/dist/scripts/generate-news-enhanced/swot-analyzer.d.ts +12 -1
- package/dist/scripts/generate-news-enhanced/swot-analyzer.d.ts.map +1 -1
- package/dist/scripts/generate-news-enhanced/swot-analyzer.js +48 -0
- package/dist/scripts/generate-news-enhanced/swot-analyzer.js.map +1 -1
- package/dist/scripts/news-types/breaking-news.d.ts.map +1 -1
- package/dist/scripts/news-types/breaking-news.js +5 -1
- package/dist/scripts/news-types/breaking-news.js.map +1 -1
- package/dist/scripts/pre-article-analysis/markdown-serializer.d.ts +64 -1
- package/dist/scripts/pre-article-analysis/markdown-serializer.d.ts.map +1 -1
- package/dist/scripts/pre-article-analysis/markdown-serializer.js.map +1 -1
- package/dist/scripts/pre-article-analysis.d.ts.map +1 -1
- package/dist/scripts/pre-article-analysis.js +20 -7
- package/dist/scripts/pre-article-analysis.js.map +1 -1
- package/dist/scripts/types/article.d.ts +33 -3
- package/dist/scripts/types/article.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/scripts/ai-analysis/coalition-detector.d.ts +0 -28
- package/dist/scripts/ai-analysis/coalition-detector.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/coalition-detector.js +0 -242
- package/dist/scripts/ai-analysis/coalition-detector.js.map +0 -1
- package/dist/scripts/ai-analysis/dashboard-analyzer.d.ts +0 -73
- package/dist/scripts/ai-analysis/dashboard-analyzer.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/dashboard-analyzer.js +0 -511
- package/dist/scripts/ai-analysis/dashboard-analyzer.js.map +0 -1
- package/dist/scripts/ai-analysis/document-analyzer.d.ts +0 -196
- package/dist/scripts/ai-analysis/document-analyzer.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/document-analyzer.js +0 -1001
- package/dist/scripts/ai-analysis/document-analyzer.js.map +0 -1
- package/dist/scripts/ai-analysis/domains/index.d.ts +0 -15
- package/dist/scripts/ai-analysis/domains/index.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/domains/index.js +0 -494
- package/dist/scripts/ai-analysis/domains/index.js.map +0 -1
- package/dist/scripts/ai-analysis/helpers.d.ts +0 -43
- package/dist/scripts/ai-analysis/helpers.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/helpers.js +0 -79
- package/dist/scripts/ai-analysis/helpers.js.map +0 -1
- package/dist/scripts/ai-analysis/index.d.ts +0 -15
- package/dist/scripts/ai-analysis/index.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/index.js +0 -14
- package/dist/scripts/ai-analysis/index.js.map +0 -1
- package/dist/scripts/ai-analysis/pipeline.d.ts +0 -41
- package/dist/scripts/ai-analysis/pipeline.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/pipeline.js +0 -208
- package/dist/scripts/ai-analysis/pipeline.js.map +0 -1
- package/dist/scripts/ai-analysis/political-significance.d.ts +0 -63
- package/dist/scripts/ai-analysis/political-significance.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/political-significance.js +0 -227
- package/dist/scripts/ai-analysis/political-significance.js.map +0 -1
- package/dist/scripts/ai-analysis/quality-assessor.d.ts +0 -104
- package/dist/scripts/ai-analysis/quality-assessor.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/quality-assessor.js +0 -554
- package/dist/scripts/ai-analysis/quality-assessor.js.map +0 -1
- package/dist/scripts/ai-analysis/swot/index.d.ts +0 -56
- package/dist/scripts/ai-analysis/swot/index.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/swot/index.js +0 -360
- package/dist/scripts/ai-analysis/swot/index.js.map +0 -1
- package/dist/scripts/ai-analysis/swot/placeholders.d.ts +0 -30
- package/dist/scripts/ai-analysis/swot/placeholders.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/swot/placeholders.js +0 -381
- package/dist/scripts/ai-analysis/swot/placeholders.js.map +0 -1
- package/dist/scripts/ai-analysis/types.d.ts +0 -333
- package/dist/scripts/ai-analysis/types.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/types.js +0 -19
- package/dist/scripts/ai-analysis/types.js.map +0 -1
- package/dist/scripts/ai-analysis/visualisation/index.d.ts +0 -15
- package/dist/scripts/ai-analysis/visualisation/index.d.ts.map +0 -1
- package/dist/scripts/ai-analysis/visualisation/index.js +0 -179
- package/dist/scripts/ai-analysis/visualisation/index.js.map +0 -1
- package/dist/scripts/analysis-framework/cross-reference.d.ts +0 -35
- package/dist/scripts/analysis-framework/cross-reference.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/cross-reference.js +0 -290
- package/dist/scripts/analysis-framework/cross-reference.js.map +0 -1
- package/dist/scripts/analysis-framework/index.d.ts +0 -79
- package/dist/scripts/analysis-framework/index.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/index.js +0 -133
- package/dist/scripts/analysis-framework/index.js.map +0 -1
- package/dist/scripts/analysis-framework/lenses/citizen.d.ts +0 -29
- package/dist/scripts/analysis-framework/lenses/citizen.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/lenses/citizen.js +0 -220
- package/dist/scripts/analysis-framework/lenses/citizen.js.map +0 -1
- package/dist/scripts/analysis-framework/lenses/economic.d.ts +0 -29
- package/dist/scripts/analysis-framework/lenses/economic.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/lenses/economic.js +0 -227
- package/dist/scripts/analysis-framework/lenses/economic.js.map +0 -1
- package/dist/scripts/analysis-framework/lenses/government.d.ts +0 -32
- package/dist/scripts/analysis-framework/lenses/government.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/lenses/government.js +0 -265
- package/dist/scripts/analysis-framework/lenses/government.js.map +0 -1
- package/dist/scripts/analysis-framework/lenses/international.d.ts +0 -29
- package/dist/scripts/analysis-framework/lenses/international.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/lenses/international.js +0 -248
- package/dist/scripts/analysis-framework/lenses/international.js.map +0 -1
- package/dist/scripts/analysis-framework/lenses/media.d.ts +0 -29
- package/dist/scripts/analysis-framework/lenses/media.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/lenses/media.js +0 -211
- package/dist/scripts/analysis-framework/lenses/media.js.map +0 -1
- package/dist/scripts/analysis-framework/lenses/opposition.d.ts +0 -29
- package/dist/scripts/analysis-framework/lenses/opposition.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/lenses/opposition.js +0 -234
- package/dist/scripts/analysis-framework/lenses/opposition.js.map +0 -1
- package/dist/scripts/analysis-framework/methodology-types.d.ts +0 -309
- package/dist/scripts/analysis-framework/methodology-types.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/methodology-types.js +0 -38
- package/dist/scripts/analysis-framework/methodology-types.js.map +0 -1
- package/dist/scripts/analysis-framework/political-classification.d.ts +0 -58
- package/dist/scripts/analysis-framework/political-classification.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/political-classification.js +0 -414
- package/dist/scripts/analysis-framework/political-classification.js.map +0 -1
- package/dist/scripts/analysis-framework/political-risk-assessment.d.ts +0 -74
- package/dist/scripts/analysis-framework/political-risk-assessment.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/political-risk-assessment.js +0 -656
- package/dist/scripts/analysis-framework/political-risk-assessment.js.map +0 -1
- package/dist/scripts/analysis-framework/political-threat-analysis.d.ts +0 -65
- package/dist/scripts/analysis-framework/political-threat-analysis.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/political-threat-analysis.js +0 -553
- package/dist/scripts/analysis-framework/political-threat-analysis.js.map +0 -1
- package/dist/scripts/analysis-framework/significance-scorer.d.ts +0 -62
- package/dist/scripts/analysis-framework/significance-scorer.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/significance-scorer.js +0 -196
- package/dist/scripts/analysis-framework/significance-scorer.js.map +0 -1
- package/dist/scripts/analysis-framework/types.d.ts +0 -138
- package/dist/scripts/analysis-framework/types.d.ts.map +0 -1
- package/dist/scripts/analysis-framework/types.js +0 -12
- package/dist/scripts/analysis-framework/types.js.map +0 -1
- package/dist/scripts/data-transformers/content-generators/ai-swot-analyzer.d.ts +0 -89
- package/dist/scripts/data-transformers/content-generators/ai-swot-analyzer.d.ts.map +0 -1
- package/dist/scripts/data-transformers/content-generators/ai-swot-analyzer.js +0 -667
- package/dist/scripts/data-transformers/content-generators/ai-swot-analyzer.js.map +0 -1
- package/dist/scripts/data-transformers/content-generators/stakeholder-swot-section.d.ts +0 -83
- package/dist/scripts/data-transformers/content-generators/stakeholder-swot-section.d.ts.map +0 -1
- package/dist/scripts/data-transformers/content-generators/stakeholder-swot-section.js +0 -219
- package/dist/scripts/data-transformers/content-generators/stakeholder-swot-section.js.map +0 -1
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module ai-analysis/political-significance
|
|
3
|
-
* @description Political significance scoring for news generation pipelines.
|
|
4
|
-
*
|
|
5
|
-
* Produces a 0–100 score reflecting a document set's overall political
|
|
6
|
-
* significance, plus an editorial urgency label. Used by:
|
|
7
|
-
* - Real-time monitor to gate article generation (≥ 60 threshold)
|
|
8
|
-
* - Breaking news generator to classify urgency
|
|
9
|
-
* - Workflow-state coordinator to prioritise high-significance articles
|
|
10
|
-
* - Article template for machine-readable metadata
|
|
11
|
-
*
|
|
12
|
-
* Scoring signals:
|
|
13
|
-
* 1. Document type weight (40 %)
|
|
14
|
-
* 2. Volume / party breadth (20 %)
|
|
15
|
-
* 3. Opposition pressure (20 %)
|
|
16
|
-
* 4. Historical rarity / topic (20 %)
|
|
17
|
-
*
|
|
18
|
-
* The function is **pure** — deterministic for the same input, no randomness.
|
|
19
|
-
*
|
|
20
|
-
* @author Hack23 AB
|
|
21
|
-
* @license Apache-2.0
|
|
22
|
-
*/
|
|
23
|
-
// ---------------------------------------------------------------------------
|
|
24
|
-
// Default threshold
|
|
25
|
-
// ---------------------------------------------------------------------------
|
|
26
|
-
/** Default minimum significance score for breaking-news generation */
|
|
27
|
-
export const BREAKING_NEWS_THRESHOLD = 60;
|
|
28
|
-
// ---------------------------------------------------------------------------
|
|
29
|
-
// Document type weights (normalised to 0-100 scale)
|
|
30
|
-
// ---------------------------------------------------------------------------
|
|
31
|
-
/**
|
|
32
|
-
* Base weight per document type, reflecting parliamentary significance.
|
|
33
|
-
* Values are on a 0-100 scale.
|
|
34
|
-
*/
|
|
35
|
-
const DOC_TYPE_WEIGHTS = {
|
|
36
|
-
prop: 60, // Government bill
|
|
37
|
-
bet: 70, // Committee report (pending vote)
|
|
38
|
-
prot: 55, // Plenary minutes
|
|
39
|
-
ip: 45, // Interpellation
|
|
40
|
-
mot: 35, // Motion
|
|
41
|
-
skr: 50, // Government communication
|
|
42
|
-
sou: 55, // Government official report (SOU)
|
|
43
|
-
ds: 40, // Departmental series
|
|
44
|
-
dir: 35, // Committee directive
|
|
45
|
-
fr: 25, // Written question
|
|
46
|
-
frs: 25, // Response to written question
|
|
47
|
-
sfs: 65, // Swedish Code of Statutes
|
|
48
|
-
fpm: 40, // EU factual memorandum
|
|
49
|
-
};
|
|
50
|
-
const DEFAULT_DOC_TYPE_WEIGHT = 30;
|
|
51
|
-
const DOC_TYPE_ALIASES = {
|
|
52
|
-
proposition: 'prop',
|
|
53
|
-
propositioner: 'prop',
|
|
54
|
-
betankande: 'bet',
|
|
55
|
-
betankanden: 'bet',
|
|
56
|
-
kommittebetankande: 'bet',
|
|
57
|
-
protokoll: 'prot',
|
|
58
|
-
interpellation: 'ip',
|
|
59
|
-
interpellationer: 'ip',
|
|
60
|
-
motion: 'mot',
|
|
61
|
-
motioner: 'mot',
|
|
62
|
-
skrivelse: 'skr',
|
|
63
|
-
fragor: 'fr',
|
|
64
|
-
fraga: 'fr',
|
|
65
|
-
fraga_svar: 'frs',
|
|
66
|
-
question: 'fr',
|
|
67
|
-
committee_report: 'bet',
|
|
68
|
-
government_bill: 'prop',
|
|
69
|
-
};
|
|
70
|
-
function normalizeDocType(doc) {
|
|
71
|
-
const fallbackType = doc.type;
|
|
72
|
-
const rawDocType = String(doc.doktyp ?? doc.documentType ?? fallbackType ?? '').trim().toLowerCase();
|
|
73
|
-
return DOC_TYPE_ALIASES[rawDocType] ?? rawDocType;
|
|
74
|
-
}
|
|
75
|
-
// ---------------------------------------------------------------------------
|
|
76
|
-
// Signal scorers (each returns 0-100)
|
|
77
|
-
// ---------------------------------------------------------------------------
|
|
78
|
-
/**
|
|
79
|
-
* Score based on the most significant document type in the set.
|
|
80
|
-
* Uses the maximum type weight across all documents.
|
|
81
|
-
*/
|
|
82
|
-
function scoreDocumentType(docs) {
|
|
83
|
-
if (docs.length === 0)
|
|
84
|
-
return 0;
|
|
85
|
-
let maxWeight = 0;
|
|
86
|
-
for (const doc of docs) {
|
|
87
|
-
const docType = normalizeDocType(doc);
|
|
88
|
-
const weight = DOC_TYPE_WEIGHTS[docType] ?? DEFAULT_DOC_TYPE_WEIGHT;
|
|
89
|
-
if (weight > maxWeight)
|
|
90
|
-
maxWeight = weight;
|
|
91
|
-
}
|
|
92
|
-
return maxWeight;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Score based on the volume of documents and breadth of parties involved.
|
|
96
|
-
* - Multiple documents increase significance (diminishing returns)
|
|
97
|
-
* - Multiple parties (signatories) increase significance
|
|
98
|
-
*/
|
|
99
|
-
function scoreVolume(docs) {
|
|
100
|
-
if (docs.length === 0)
|
|
101
|
-
return 0;
|
|
102
|
-
// Volume: logarithmic scaling for document count
|
|
103
|
-
const volumeScore = Math.min(50, Math.round(Math.log2(docs.length + 1) * 15));
|
|
104
|
-
// Party breadth: unique parties involved
|
|
105
|
-
const parties = new Set();
|
|
106
|
-
for (const doc of docs) {
|
|
107
|
-
const party = doc.parti;
|
|
108
|
-
if (party)
|
|
109
|
-
parties.add(party.toUpperCase());
|
|
110
|
-
}
|
|
111
|
-
const partyScore = Math.min(50, parties.size * 10);
|
|
112
|
-
return Math.min(100, volumeScore + partyScore);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Score based on opposition pressure: interpellations per unique minister.
|
|
116
|
-
* High interpellation density (multiple IPs to same minister) signals
|
|
117
|
-
* concentrated political pressure.
|
|
118
|
-
*/
|
|
119
|
-
function scoreOppositionPressure(docs) {
|
|
120
|
-
const interpellations = docs.filter(d => normalizeDocType(d) === 'ip');
|
|
121
|
-
if (interpellations.length === 0)
|
|
122
|
-
return 0;
|
|
123
|
-
// Count IPs per minister (mottagare)
|
|
124
|
-
const ministerCounts = new Map();
|
|
125
|
-
for (const ip of interpellations) {
|
|
126
|
-
const minister = (ip.mottagare ?? '').trim();
|
|
127
|
-
if (!minister)
|
|
128
|
-
continue;
|
|
129
|
-
ministerCounts.set(minister, (ministerCounts.get(minister) || 0) + 1);
|
|
130
|
-
}
|
|
131
|
-
if (ministerCounts.size === 0)
|
|
132
|
-
return 0;
|
|
133
|
-
// Max pressure on any single minister
|
|
134
|
-
let maxPressure = 0;
|
|
135
|
-
for (const count of ministerCounts.values()) {
|
|
136
|
-
if (count > maxPressure)
|
|
137
|
-
maxPressure = count;
|
|
138
|
-
}
|
|
139
|
-
// Scale: 1 IP = 20, 2 = 40, 3 = 60, 4 = 80, 5+ = 100
|
|
140
|
-
return Math.min(100, maxPressure * 20);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Score based on historical rarity: whether documents' topics appear
|
|
144
|
-
* in a set of recently covered topics.
|
|
145
|
-
*
|
|
146
|
-
* Documents covering topics NOT seen in the recent window score higher
|
|
147
|
-
* (novel topics are more newsworthy).
|
|
148
|
-
*
|
|
149
|
-
* @param docs - Current document set
|
|
150
|
-
* @param recentTopics - Topics covered in the last 30 days (titles/keywords)
|
|
151
|
-
*/
|
|
152
|
-
function scoreTopicRarity(docs, recentTopics) {
|
|
153
|
-
if (docs.length === 0)
|
|
154
|
-
return 0;
|
|
155
|
-
const recentLower = new Set(recentTopics.map(t => t.toLowerCase()));
|
|
156
|
-
// Minimum length for a recent topic to be considered for substring matching.
|
|
157
|
-
// Very short strings (≤ 3 chars) cause false positives (e.g. "tax" matching "syntax").
|
|
158
|
-
const MIN_TOPIC_LENGTH_FOR_MATCH = 4;
|
|
159
|
-
let novelCount = 0;
|
|
160
|
-
for (const doc of docs) {
|
|
161
|
-
const title = (doc.titel || doc.title || '').toLowerCase();
|
|
162
|
-
if (title.length === 0)
|
|
163
|
-
continue;
|
|
164
|
-
// If none of the recent topics appear as a substring, it's novel
|
|
165
|
-
let isNovel = true;
|
|
166
|
-
for (const recent of recentLower) {
|
|
167
|
-
if (recent.length >= MIN_TOPIC_LENGTH_FOR_MATCH && title.includes(recent)) {
|
|
168
|
-
isNovel = false;
|
|
169
|
-
break;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (isNovel)
|
|
173
|
-
novelCount++;
|
|
174
|
-
}
|
|
175
|
-
const novelRatio = novelCount / docs.length;
|
|
176
|
-
return Math.round(novelRatio * 100);
|
|
177
|
-
}
|
|
178
|
-
// ---------------------------------------------------------------------------
|
|
179
|
-
// Urgency classification
|
|
180
|
-
// ---------------------------------------------------------------------------
|
|
181
|
-
/**
|
|
182
|
-
* Map a 0-100 score to an editorial urgency label.
|
|
183
|
-
*/
|
|
184
|
-
export function classifyUrgency(score) {
|
|
185
|
-
if (score >= 80)
|
|
186
|
-
return 'breaking';
|
|
187
|
-
if (score >= 60)
|
|
188
|
-
return 'major';
|
|
189
|
-
if (score >= 40)
|
|
190
|
-
return 'standard';
|
|
191
|
-
return 'background';
|
|
192
|
-
}
|
|
193
|
-
// ---------------------------------------------------------------------------
|
|
194
|
-
// Public API
|
|
195
|
-
// ---------------------------------------------------------------------------
|
|
196
|
-
/**
|
|
197
|
-
* Score a set of parliamentary documents for political significance.
|
|
198
|
-
*
|
|
199
|
-
* The function is **deterministic**: identical inputs always produce
|
|
200
|
-
* identical outputs (no randomness, no date-dependent logic beyond
|
|
201
|
-
* the explicit `recentTopics` parameter).
|
|
202
|
-
*
|
|
203
|
-
* @param docs - Documents to score
|
|
204
|
-
* @param recentTopics - Topics covered in the last 30 days (for rarity signal).
|
|
205
|
-
* Pass an empty array when historical context is unavailable.
|
|
206
|
-
* @returns Composite significance score (0-100), urgency label, and signal breakdown
|
|
207
|
-
*/
|
|
208
|
-
export function scoreDocuments(docs, recentTopics = []) {
|
|
209
|
-
const docTypeValue = scoreDocumentType(docs);
|
|
210
|
-
const volumeValue = scoreVolume(docs);
|
|
211
|
-
const pressureValue = scoreOppositionPressure(docs);
|
|
212
|
-
const rarityValue = scoreTopicRarity(docs, recentTopics);
|
|
213
|
-
const signals = [
|
|
214
|
-
{ signal: 'documentType', weight: 0.40, value: docTypeValue },
|
|
215
|
-
{ signal: 'volume', weight: 0.20, value: volumeValue },
|
|
216
|
-
{ signal: 'oppositionPressure', weight: 0.20, value: pressureValue },
|
|
217
|
-
{ signal: 'topicRarity', weight: 0.20, value: rarityValue },
|
|
218
|
-
];
|
|
219
|
-
const raw = signals.reduce((sum, s) => sum + s.value * s.weight, 0);
|
|
220
|
-
const score = Math.max(0, Math.min(100, Math.round(raw)));
|
|
221
|
-
return {
|
|
222
|
-
score,
|
|
223
|
-
urgency: classifyUrgency(score),
|
|
224
|
-
signals,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
//# sourceMappingURL=political-significance.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"political-significance.js","sourceRoot":"","sources":["../../../scripts/ai-analysis/political-significance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA+BH,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E,sEAAsE;AACtE,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,8EAA8E;AAC9E,oDAAoD;AACpD,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,gBAAgB,GAAqC;IACzD,IAAI,EAAE,EAAE,EAAI,kBAAkB;IAC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,eAAyB,EAAE;IAE3B,MAAM,YAAY,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,aAAa,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAEzD,MAAM,OAAO,GAAyB;QACpC,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE;QAC7D,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE;QACtD,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE;QACpE,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE;KAC5D,CAAC;IAEF,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACpE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAE1D,OAAO;QACL,KAAK;QACL,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC;QAC/B,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module ai-analysis/quality-assessor
|
|
3
|
-
* @description Multi-dimensional quality assessment for generated news articles.
|
|
4
|
-
*
|
|
5
|
-
* Implements a 6-dimension quality scoring framework:
|
|
6
|
-
* 1. Factual Accuracy (25%) — document references match source material
|
|
7
|
-
* 2. Stakeholder Coverage (20%) — all relevant perspectives represented
|
|
8
|
-
* 3. Analytical Depth (20%) — substance beyond surface description
|
|
9
|
-
* 4. Editorial Consistency (15%) — consistent tone, structure, headings
|
|
10
|
-
* 5. Evidence Quality (10%) — assertions backed by document references
|
|
11
|
-
* 6. Language Quality (10%) — word count, clarity, readability
|
|
12
|
-
*
|
|
13
|
-
* The assessor runs as two passes:
|
|
14
|
-
* Pass 1 — compute dimension scores from HTML content
|
|
15
|
-
* Pass 2 — aggregate, flag issues, build suggestions list
|
|
16
|
-
*
|
|
17
|
-
* @author Hack23 AB
|
|
18
|
-
* @license Apache-2.0
|
|
19
|
-
*/
|
|
20
|
-
/** Score for a single quality dimension */
|
|
21
|
-
export interface DimensionScore {
|
|
22
|
-
/** 0–100 score for this dimension */
|
|
23
|
-
score: number;
|
|
24
|
-
/** Evidence items used to compute the score */
|
|
25
|
-
evidence: string[];
|
|
26
|
-
/** Suggested improvements for this dimension */
|
|
27
|
-
improvements: string[];
|
|
28
|
-
}
|
|
29
|
-
/** Severity of a quality issue */
|
|
30
|
-
export type QualityIssueSeverity = 'critical' | 'major' | 'minor';
|
|
31
|
-
/** A single quality problem found in the article */
|
|
32
|
-
export interface QualityIssue {
|
|
33
|
-
severity: QualityIssueSeverity;
|
|
34
|
-
dimension: string;
|
|
35
|
-
description: string;
|
|
36
|
-
suggestedFix: string;
|
|
37
|
-
}
|
|
38
|
-
/** Full multi-dimensional quality assessment result */
|
|
39
|
-
export interface MultiDimensionalQualityAssessment {
|
|
40
|
-
/** 0–100 weighted overall score */
|
|
41
|
-
overallScore: number;
|
|
42
|
-
/** Per-dimension scores */
|
|
43
|
-
dimensions: {
|
|
44
|
-
factualAccuracy: DimensionScore;
|
|
45
|
-
stakeholderCoverage: DimensionScore;
|
|
46
|
-
analyticalDepth: DimensionScore;
|
|
47
|
-
editorialConsistency: DimensionScore;
|
|
48
|
-
evidenceQuality: DimensionScore;
|
|
49
|
-
languageQuality: DimensionScore;
|
|
50
|
-
};
|
|
51
|
-
/** Issues detected (sorted: critical → major → minor) */
|
|
52
|
-
issues: QualityIssue[];
|
|
53
|
-
/** Suggested improvements */
|
|
54
|
-
suggestions: string[];
|
|
55
|
-
/** Whether the article passes the quality threshold */
|
|
56
|
-
passesThreshold: boolean;
|
|
57
|
-
/** Number of assessment passes performed (always ≥ 2) */
|
|
58
|
-
assessmentPasses: number;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Run multi-dimensional quality assessment on a generated article.
|
|
62
|
-
*
|
|
63
|
-
* The assessment performs two passes:
|
|
64
|
-
* Pass 1 — compute all six dimension scores from the HTML content
|
|
65
|
-
* Pass 2 — aggregate dimensions into a weighted overall score and build the issues list
|
|
66
|
-
*
|
|
67
|
-
* Always returns `assessmentPasses >= 2`.
|
|
68
|
-
*
|
|
69
|
-
* @param html - Full HTML content of the article
|
|
70
|
-
* @param lang - ISO 639-1 language code (e.g. "en")
|
|
71
|
-
* @param sourceDocIds - Document IDs available in the source data for cross-checking
|
|
72
|
-
* @param passThreshold - Minimum overall score to pass (0–100, default 60)
|
|
73
|
-
*/
|
|
74
|
-
export declare function assessArticleQuality(html: string, lang: string, sourceDocIds?: readonly string[], passThreshold?: number): MultiDimensionalQualityAssessment;
|
|
75
|
-
/**
|
|
76
|
-
* Render a quality assessment as a concise console report.
|
|
77
|
-
*/
|
|
78
|
-
export declare function printQualityReport(assessment: MultiDimensionalQualityAssessment, filename: string): void;
|
|
79
|
-
/**
|
|
80
|
-
* Inject quality metadata into article HTML as a `<meta>` tag and,
|
|
81
|
-
* optionally, an inline JSON-LD block.
|
|
82
|
-
*
|
|
83
|
-
* **CSP note:** An inline `<script type="application/ld+json">` element is
|
|
84
|
-
* still an inline script from the browser's perspective. If the page's
|
|
85
|
-
* Content-Security-Policy sets `script-src` without `'unsafe-inline'`, the
|
|
86
|
-
* JSON-LD block will be blocked by the browser. To keep things safe:
|
|
87
|
-
*
|
|
88
|
-
* - The `<meta name="quality-score">` tag is injected when a `</head>`
|
|
89
|
-
* insertion point is found (CSP-safe).
|
|
90
|
-
* - The JSON-LD `<script>` block is only injected when `injectJsonLd` is
|
|
91
|
-
* `true` (default: `false`). Callers that know their CSP allows inline
|
|
92
|
-
* scripts can opt in.
|
|
93
|
-
* - If the HTML contains no `</head>` tag the function returns the original
|
|
94
|
-
* HTML unchanged (no injection possible without a `<head>` section).
|
|
95
|
-
*
|
|
96
|
-
* @param html - Original article HTML
|
|
97
|
-
* @param assessment - Quality assessment result
|
|
98
|
-
* @param injectJsonLd - If `true`, also add the JSON-LD script block
|
|
99
|
-
* (requires CSP to permit inline scripts). Default: `false`.
|
|
100
|
-
* @returns Modified HTML with quality metadata injected, or the
|
|
101
|
-
* original HTML if no `</head>` tag is present.
|
|
102
|
-
*/
|
|
103
|
-
export declare function injectQualityMetadata(html: string, assessment: MultiDimensionalQualityAssessment, injectJsonLd?: boolean): string;
|
|
104
|
-
//# sourceMappingURL=quality-assessor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quality-assessor.d.ts","sourceRoot":"","sources":["../../../scripts/ai-analysis/quality-assessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,gDAAgD;IAChD,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,kCAAkC;AAClC,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC;AAElE,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MA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