Skip to content

Commit

Permalink
added new detectionType
Browse files Browse the repository at this point in the history
  • Loading branch information
rosannamilner committed Dec 10, 2024
1 parent b5bb278 commit 3ab9f14
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,63 +102,6 @@ const AssistantCredSignals = () => {
},
}));

// assistant media states
const text = useSelector((state) => state.assistant.urlText);
const textLang = useSelector((state) => state.assistant.textLang);
const textHtmlMap = useSelector((state) => state.assistant.urlTextHtmlMap);

// news framing (topic)
const newsFramingTitle = keyword("news_framing_title");
const newsFramingResult = useSelector(
(state) => state.assistant.newsFramingResult,
);
const newsFramingLoading = useSelector(
(state) => state.assistant.newsFramingLoading,
);
const newsFramingDone = useSelector(
(state) => state.assistant.newsFramingDone,
);
const newsFramingFail = useSelector(
(state) => state.assistant.newsFramingFail,
);

// news genre
const newsGenreTitle = keyword("news_genre_title");
const newsGenreResult = useSelector(
(state) => state.assistant.newsGenreResult,
);
const newsGenreLoading = useSelector(
(state) => state.assistant.newsGenreLoading,
);
const newsGenreDone = useSelector((state) => state.assistant.newsGenreDone);
const newsGenreFail = useSelector((state) => state.assistant.newsGenreFail);

// persuasion techniques
const persuasionTitle = keyword("persuasion_techniques_title");
const persuasionResult = useSelector(
(state) => state.assistant.persuasionResult,
);
const persuasionLoading = useSelector(
(state) => state.assistant.persuasionLoading,
);
const persuasionDone = useSelector((state) => state.assistant.persuasionDone);
const persuasionFail = useSelector((state) => state.assistant.persuasionFail);

// subjectivity
const subjectivityTitle = keyword("subjectivity_title");
const subjectivityResult = useSelector(
(state) => state.assistant.subjectivityResult,
);
const subjectivityLoading = useSelector(
(state) => state.assistant.subjectivityLoading,
);
const subjectivityDone = useSelector(
(state) => state.assistant.subjectivityDone,
);
const subjectivityFail = useSelector(
(state) => state.assistant.subjectivityFail,
);

// previous fact checks
const prevFactChecksTitle = keyword("previous_fact_checks_title");
const prevFactChecksResult = useSelector(
Expand Down Expand Up @@ -215,7 +158,7 @@ const AssistantCredSignals = () => {
];
const colors = ["#00FF00", "#AAFF03", "#FFA903", "#FF0000"];

//const methodName = "machinegeneratedtext";
// methodName = "machinegeneratedtext"
const MachineGeneratedTextMethodNames = {
machinegeneratedtext: {
name: keyword("machine_generated_text_title"),
Expand Down Expand Up @@ -251,22 +194,6 @@ const AssistantCredSignals = () => {
__html:
keyword("credibility_signals_tooltip") +
"<br><br><b>" +
// keyword("news_framing") +
// "</b><br>" +
// keyword("news_framing_tooltip") +
// "<br><br><b>" +
// keyword("news_genre") +
// "</b><br>" +
// keyword("news_genre_tooltip") +
// "<br><br><b>" +
// keyword("persuasion_techniques") +
// "</b><br>" +
// keyword("persuasion_techniques_tooltip") +
// "<br><br><b>" +
// keyword("subjectivity") +
// "</b><br>" +
// keyword("subjectivity_tooltip") +
// "<br><br><b>" +
keyword("previous_fact_checks_title") +
"</b><br>" +
keyword("previous_fact_checks_tooltip") +
Expand Down Expand Up @@ -509,8 +436,8 @@ const AssistantCredSignals = () => {
resultsHaveErrors={false}
sanitizeDetectionPercentage={(n) => Math.round(n)}
gaugeExplanation={{ colors: colors, keywords: keywords }}
toolName={keyword("machine_generated_text_title")}
detectionType={"text"}
toolName="Assistant" // this points to the correct translatons .tsv file
detectionType={"machine_generated_text"}
/>
) : null}
</AccordionDetails>
Expand Down
19 changes: 14 additions & 5 deletions src/components/Shared/CustomAlertScore/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const CustomAlertScore = ({
VOICE_RECORDING: "replay",
IMAGE: "image",
VIDEO: "video",
MACHINE_GENERATED_TEXT: "machine_generated_text",
};

const toolNameSnakeCase = toolName
Expand Down Expand Up @@ -65,6 +66,8 @@ const CustomAlertScore = ({
return "_image";
} else if (detectionType === DETECTION_TYPES.VIDEO) {
return "_video";
} else if (detectionType === DETECTION_TYPES.MACHINE_GENERATED_TEXT) {
return "_machine_generated_text";
} else return "";
}
};
Expand All @@ -82,31 +85,35 @@ const CustomAlertScore = ({
!detectionType ||
detectionType === DETECTION_TYPES.VOICE_CLONING ||
detectionType === DETECTION_TYPES.VIDEO ||
detectionType === DETECTION_TYPES.IMAGE
detectionType === DETECTION_TYPES.IMAGE ||
detectionType === DETECTION_TYPES.MACHINE_GENERATED_TEXT
? keyword(`${toolNameSnakeCase}${detectionTranslation}_rating_4`)
: keyword(`loccus_voice_recording_detection_rating_4`);
} else if (score >= DETECTION_THRESHOLD_2) {
displayText +=
!detectionType ||
detectionType === DETECTION_TYPES.VOICE_CLONING ||
detectionType === DETECTION_TYPES.VIDEO ||
detectionType === DETECTION_TYPES.IMAGE
detectionType === DETECTION_TYPES.IMAGE ||
detectionType === DETECTION_TYPES.MACHINE_GENERATED_TEXT
? keyword(`${toolNameSnakeCase}${detectionTranslation}_rating_3`)
: keyword(`loccus_voice_recording_detection_rating_3`);
} else if (score >= DETECTION_THRESHOLD_1) {
displayText +=
!detectionType ||
detectionType === DETECTION_TYPES.VOICE_CLONING ||
detectionType === DETECTION_TYPES.VIDEO ||
detectionType === DETECTION_TYPES.IMAGE
detectionType === DETECTION_TYPES.IMAGE ||
detectionType === DETECTION_TYPES.MACHINE_GENERATED_TEXT
? keyword(`${toolNameSnakeCase}${detectionTranslation}_rating_2`)
: keyword(`loccus_voice_recording_detection_rating_2`);
} else {
displayText +=
!detectionType ||
detectionType === DETECTION_TYPES.VOICE_CLONING ||
detectionType === DETECTION_TYPES.VIDEO ||
detectionType === DETECTION_TYPES.IMAGE
detectionType === DETECTION_TYPES.IMAGE ||
detectionType === DETECTION_TYPES.MACHINE_GENERATED_TEXT
? keyword(`${toolNameSnakeCase}${detectionTranslation}_rating_1`)
: keyword(`loccus_voice_recording_detection_rating_1`);
}
Expand All @@ -133,7 +140,9 @@ const CustomAlertScore = ({
/>
}
>
<Typography variant="body1">{alertSettings.displayText}</Typography>
<Typography variant="body1" align="start">
{alertSettings.displayText}
</Typography>
</Alert>
);
};
Expand Down
4 changes: 3 additions & 1 deletion src/components/Shared/GaugeChartResults/GaugeChartResult.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ const GaugeChartResult = ({
<Typography
variant={"h6"}
sx={{ fontWeight: "bold" }}
></Typography>
>
{methodNames[item.methodName].name}
</Typography>
<Stack
direction={{ lg: "row", md: "column" }}
spacing={2}
Expand Down

0 comments on commit 3ab9f14

Please sign in to comment.