Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export default function AssistantTextClassification({
"likely_machine",
"highly_likely_machine",
],
// news framing
newsFramingConfidenceThreshold: 0.8,
// news genre
newsGenreConfidenceThresholdLow: 0.7,
},
textHtmlMap = null,
credibilitySignal = "",
Expand Down Expand Up @@ -97,14 +101,13 @@ export default function AssistantTextClassification({
const mgtOverallScoreLabel = "mgt_overall_score";

// define colours
let newsFramingConfidenceThreshold, newsGenreConfidenceThreshold;
let mgtColours, mgtColoursDark, orderedCategories;
let subjectivityColours, subjectivityColoursDark;
let confidenceThresholdLow;
if (
credibilitySignal === newsFramingTitle ||
credibilitySignal === newsGenreTitle
) {
confidenceThresholdLow = configs.confidenceThresholdLow;
if (credibilitySignal === newsFramingTitle) {
newsFramingConfidenceThreshold = configs.newsFramingConfidenceThreshold;
} else if (credibilitySignal === newsGenreTitle) {
newsGenreConfidenceThreshold = configs.newsGenreConfidenceThreshold;
} else if (credibilitySignal === machineGeneratedTextTitle) {
[mgtColours, mgtColoursDark] = getMgtColours(configs);
orderedCategories = configs.orderedCategories;
Expand All @@ -121,6 +124,8 @@ export default function AssistantTextClassification({
let filteredSentences = [];
let filteredCategories = {};

const REPORTING_LABEL = "Reporting";

// Separate important sentences from categories, filter by threshold
for (let label in classification) {
if (label === importantSentenceKey) {
Expand All @@ -137,16 +142,25 @@ export default function AssistantTextClassification({
}
}
} else {
// Filter categories above confidenceThreshold unless machine generated text or subjectivity
// machine generated text and subjectivity
if (
credibilitySignal === machineGeneratedTextTitle ||
credibilitySignal === subjectivityTitle
) {
filteredCategories[label] = classification[label];
} else if (credibilitySignal === newsGenreTitle) {
// set default news genre value if category below threshold
label === REPORTING_LABEL
? (filteredCategories[label] = classification[label])
: classification[label][0].score >= newsGenreConfidenceThreshold
? (filteredCategories[label] = classification[label])
: (filteredCategories[REPORTING_LABEL] = [
{ indices: [0, -1], score: newsGenreConfidenceThreshold },
]);
} else if (
// news framing and news genre
classification[label][0].score >= confidenceThresholdLow
classification[label][0].score >= newsFramingConfidenceThreshold
) {
// filter news framing categories above threshold
filteredCategories[label] = classification[label];
}
}
Expand Down