Skip to content

Commit fa53505

Browse files
Merge pull request #1069 from LAION-AI/flag-label-desciptions
website: show descriptions for label flags
2 parents 242a1e6 + b1d86eb commit fa53505

File tree

3 files changed

+40
-19
lines changed

3 files changed

+40
-19
lines changed

website/public/locales/en/labelling.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@
88
"spam.question": "Is the message spam?",
99
"fails_task.question": "Is it a bad reply, as an answer to the prompt task?",
1010
"not_appropriate": "Not Appropriate",
11+
"not_appropriate.explanation": "Inappropriate for a customer assistant.",
1112
"pii": "Contains PII",
13+
"pii.explanation": "Contains personally identifying information. Examples include personal contact details, license and other identity numbers and banking details.",
1214
"hate_speech": "Hate Speech",
15+
"hate_speech.explanation": "Content is abusive or threatening and expresses prejudice against a protected characteristic. Prejudice refers to preconceived views not based on reason. Protected characteristics include gender, ethnicity, religion, sexual orientation, and similar characteristics.",
1316
"sexual_content": "Sexual Content",
17+
"sexual_content.explanation": "Contains sexual content.",
1418
"moral_judgement": "Judges Morality",
19+
"moral_judgement.explanation": "Expresses moral judgement.",
1520
"political_content": "Political",
16-
"lang_mismatch": "Wrong Language"
21+
"political_content.explanation": "Expresses political views.",
22+
"lang_mismatch": "Wrong Language",
23+
"lang_mismatch.explanation": "Not written in the currently selected language."
1724
}

website/src/components/Messages/LabelFlagGroup.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button, Flex } from "@chakra-ui/react";
1+
import { Button, Flex, Tooltip } from "@chakra-ui/react";
22
import { useTranslation } from "next-i18next";
33
import { getTypeSafei18nKey } from "src/lib/i18n";
44

@@ -14,18 +14,19 @@ export const LabelFlagGroup = ({ values, labelNames, isEditable = true, onChange
1414
return (
1515
<Flex wrap="wrap" gap="4">
1616
{labelNames.map((name, idx) => (
17-
<Button
18-
key={name}
19-
onClick={() => {
20-
const newValues = values.slice();
21-
newValues[idx] = newValues[idx] ? 0 : 1;
22-
onChange(newValues);
23-
}}
24-
isDisabled={!isEditable}
25-
colorScheme={values[idx] === 1 ? "blue" : undefined}
26-
>
27-
{t(getTypeSafei18nKey(name))}
28-
</Button>
17+
<Tooltip key={name} label={`${t(getTypeSafei18nKey(`${name}.explanation`))}`}>
18+
<Button
19+
onClick={() => {
20+
const newValues = values.slice();
21+
newValues[idx] = newValues[idx] ? 0 : 1;
22+
onChange(newValues);
23+
}}
24+
isDisabled={!isEditable}
25+
colorScheme={values[idx] === 1 ? "blue" : undefined}
26+
>
27+
{t(getTypeSafei18nKey(name))}
28+
</Button>
29+
</Tooltip>
2930
))}
3031
</Flex>
3132
);

website/src/components/Messages/LabelInputGroup.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Text, VStack } from "@chakra-ui/react";
2+
import { useTranslation } from "next-i18next";
3+
import { Explain } from "src/components/Explain";
4+
import { LabelFlagGroup } from "src/components/Messages/LabelFlagGroup";
5+
import { LabelLikertGroup } from "src/components/Survey/LabelLikertGroup";
6+
import { LabelYesNoGroup } from "src/components/Messages/LabelYesNoGroup";
7+
import { getTypeSafei18nKey } from "src/lib/i18n";
28
import { Label } from "src/types/Tasks";
39

4-
import { LabelLikertGroup } from "../Survey/LabelLikertGroup";
5-
import { LabelFlagGroup } from "./LabelFlagGroup";
6-
import { LabelYesNoGroup } from "./LabelYesNoGroup";
7-
810
export interface LabelInputInstructions {
911
yesNoInstruction: string;
1012
flagInstruction: string;
@@ -28,6 +30,7 @@ export const LabelInputGroup = ({
2830
instructions,
2931
onChange,
3032
}: LabelInputGroupProps) => {
33+
const { t } = useTranslation("labelling");
3134
const yesNoIndexes = labels.map((label, idx) => (label.widget === "yes_no" ? idx : null)).filter((v) => v !== null);
3235
const flagIndexes = labels.map((label, idx) => (label.widget === "flag" ? idx : null)).filter((v) => v !== null);
3336
const likertIndexes = labels.map((label, idx) => (label.widget === "likert" ? idx : null)).filter((v) => v !== null);
@@ -52,7 +55,17 @@ export const LabelInputGroup = ({
5255
)}
5356
{flagIndexes.length > 0 && (
5457
<VStack alignItems="stretch" spacing={2}>
55-
<Text>{instructions.flagInstruction}</Text>
58+
<Text>
59+
{instructions.flagInstruction}
60+
<Explain
61+
explanation={flagIndexes.map(
62+
(idx) =>
63+
`${t(getTypeSafei18nKey(labels[idx].name))}: ${t(
64+
getTypeSafei18nKey(`${labels[idx].name}.explanation`)
65+
)}`
66+
)}
67+
/>{" "}
68+
</Text>
5669
<LabelFlagGroup
5770
values={flagIndexes.map((idx) => values[idx])}
5871
labelNames={flagIndexes.map((idx) => labels[idx].name)}

0 commit comments

Comments
 (0)