@cosla/sensemaking-report-builder 0.1.0 → 0.1.1
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 +1 -1
- package/data.js +39 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ Same shape as Python `sensemaking-report-text` / `report_data.json`: `text`, `su
|
|
|
90
90
|
| `low_sample_warning_threshold` | Low-sample warning threshold |
|
|
91
91
|
| `topic_colors` / `chart_colors` | Overview chart colours |
|
|
92
92
|
| `demographic_colors` | Participant chart colours |
|
|
93
|
-
| `
|
|
93
|
+
| `excluded_topics` / `excluded_opinions` | Hide named topics/opinions (exact match to CSV columns) |
|
|
94
94
|
|
|
95
95
|
### Predicted agreement (optional)
|
|
96
96
|
|
package/data.js
CHANGED
|
@@ -380,6 +380,8 @@ export function processReportData({
|
|
|
380
380
|
}
|
|
381
381
|
|
|
382
382
|
const overviewChart = config.overview_chart || "toggle";
|
|
383
|
+
const excludedTopics = new Set(config.excluded_topics || []);
|
|
384
|
+
const excludedOpinions = new Set(config.excluded_opinions || []);
|
|
383
385
|
const reportOptions = {
|
|
384
386
|
logo: config.logo || "",
|
|
385
387
|
overviewChart,
|
|
@@ -441,34 +443,43 @@ export function processReportData({
|
|
|
441
443
|
* @returns {Object[]}
|
|
442
444
|
*/
|
|
443
445
|
function groupOpinions(opinionsList) {
|
|
444
|
-
const byTopic = groupBy(opinionsList, "topic")
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
)
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
446
|
+
const byTopic = groupBy(opinionsList, "topic").filter(
|
|
447
|
+
([topicText]) => !excludedTopics.has(topicText),
|
|
448
|
+
);
|
|
449
|
+
return byTopic
|
|
450
|
+
.map(([topicText, topicOpinions]) => {
|
|
451
|
+
const topicMatch = (summary.sub_contents || []).find(
|
|
452
|
+
(t) => stripMarkdownHeader(t.title) === topicText,
|
|
453
|
+
);
|
|
454
|
+
const topicId = generateId(topicText, true);
|
|
455
|
+
const keptOpinions = topicOpinions.filter(
|
|
456
|
+
(row) => !excludedOpinions.has(row.opinion),
|
|
457
|
+
);
|
|
458
|
+
const byOpinion = groupBy(keptOpinions, "opinion").map(
|
|
459
|
+
([_, values]) => ({
|
|
460
|
+
opinionID: generateId(values[0].opinion),
|
|
461
|
+
fullID: `${topicId}-${generateId(values[0].opinion)}`,
|
|
462
|
+
text: values[0].opinion,
|
|
463
|
+
count: values.length,
|
|
464
|
+
quotes: sortAndExtractQuotes(values),
|
|
465
|
+
}),
|
|
466
|
+
);
|
|
463
467
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
468
|
+
byOpinion.sort((a, b) => {
|
|
469
|
+
if (a.text === "Other") return 1;
|
|
470
|
+
if (b.text === "Other") return -1;
|
|
471
|
+
return b.count - a.count;
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
return {
|
|
475
|
+
topicID: topicId,
|
|
476
|
+
summary: cleanMarkdown(topicMatch?.text),
|
|
477
|
+
text: topicText,
|
|
478
|
+
count: keptOpinions.length,
|
|
479
|
+
opinions: byOpinion,
|
|
480
|
+
};
|
|
481
|
+
})
|
|
482
|
+
.filter((topic) => topic.opinions.length > 0);
|
|
472
483
|
}
|
|
473
484
|
|
|
474
485
|
/**
|
|
@@ -587,7 +598,7 @@ export function processReportData({
|
|
|
587
598
|
const quotes = flattenQuotes(opinionsGrouped);
|
|
588
599
|
const predicted = processPredicted(predictedRaw);
|
|
589
600
|
|
|
590
|
-
const topicsIdentified =
|
|
601
|
+
const topicsIdentified = opinionsGrouped.length;
|
|
591
602
|
const topicsIdentifiedFormatted = formatNumber(topicsIdentified);
|
|
592
603
|
const opinionsIdentified = opinionsGrouped
|
|
593
604
|
.map((t) => t.opinions.length)
|