@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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/data.js +39 -28
  3. 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
- | `excludedTopics` / `excludedOpinions` | Hide named topics/opinions |
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
- return byTopic.map(([topicText, topicOpinions]) => {
446
- const topicMatch = (summary.sub_contents || []).find(
447
- (t) => stripMarkdownHeader(t.title) === topicText,
448
- );
449
- const topicId = generateId(topicText, true);
450
- const byOpinion = groupBy(topicOpinions, "opinion").map(([_, values]) => ({
451
- opinionID: generateId(values[0].opinion),
452
- fullID: `${topicId}-${generateId(values[0].opinion)}`,
453
- text: values[0].opinion,
454
- count: values.length,
455
- quotes: sortAndExtractQuotes(values),
456
- }));
457
-
458
- byOpinion.sort((a, b) => {
459
- if (a.text === "Other") return 1;
460
- if (b.text === "Other") return -1;
461
- return b.count - a.count;
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
- return {
465
- topicID: topicId,
466
- summary: cleanMarkdown(topicMatch?.text),
467
- text: topicText,
468
- count: topicOpinions.length,
469
- opinions: byOpinion,
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 = (summary.sub_contents || []).length;
601
+ const topicsIdentified = opinionsGrouped.length;
591
602
  const topicsIdentifiedFormatted = formatNumber(topicsIdentified);
592
603
  const opinionsIdentified = opinionsGrouped
593
604
  .map((t) => t.opinions.length)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosla/sensemaking-report-builder",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Interactive HTML report builder for Cosla Python sensemaking pipeline outputs.",
5
5
  "type": "module",
6
6
  "main": "build.js",