Skip to content

Commit 8949667

Browse files
committed
added default genre if category with highest score below threshold
1 parent cf921ee commit 8949667

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/components/NavItems/Assistant/AssistantScrapeResults/AssistantTextClassification.jsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ export default function AssistantTextClassification({
121121
let filteredSentences = [];
122122
let filteredCategories = {};
123123

124+
const REPORTING_LABEL = "Reporting";
125+
124126
// Separate important sentences from categories, filter by threshold
125127
for (let label in classification) {
126128
if (label === importantSentenceKey) {
@@ -137,16 +139,23 @@ export default function AssistantTextClassification({
137139
}
138140
}
139141
} else {
140-
// Filter categories above confidenceThreshold unless machine generated text or subjectivity
142+
// machine generated text and subjectivity
141143
if (
142144
credibilitySignal === machineGeneratedTextTitle ||
143145
credibilitySignal === subjectivityTitle
144146
) {
145147
filteredCategories[label] = classification[label];
146-
} else if (
147-
// news framing and news genre
148-
classification[label][0].score >= confidenceThresholdLow
149-
) {
148+
} else if (credibilitySignal === keyword("news_genre_title")) {
149+
// set default news genre value if category below threshold
150+
label === REPORTING_LABEL
151+
? (filteredCategories[label] = classification[label])
152+
: classification[label][0].score >= confidenceThresholdLow
153+
? (filteredCategories[label] = classification[label])
154+
: (filteredCategories[REPORTING_LABEL] = [
155+
{ indices: [0, -1], score: confidenceThresholdLow },
156+
]);
157+
} else if (classification[label][0].score >= confidenceThresholdLow) {
158+
// filter news framing categories above threshold
150159
filteredCategories[label] = classification[label];
151160
}
152161
}

0 commit comments

Comments
 (0)