Skip to content

Commit

Permalink
added translations for all genres, topics and persuasion
Browse files Browse the repository at this point in the history
  • Loading branch information
rosannamilner committed Aug 13, 2024
1 parent 7e2c787 commit 97c5987
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 23 deletions.
35 changes: 35 additions & 0 deletions public/locales/en/components/NavItems/tools/Assistant.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,45 @@
"colour_scale": "The colour scale is shown below:",
"news_framing": "Topic",
"news_framing_tooltip": "Identify the topics used in the extracted text. A topic is the perspective under which an issue or a piece of news is presented. A total of 9 different topics are considered.",
"Economy_and_Resources": "Economy and Resources",
"Religious_Ethical_and_Cultural": "Religious, Ethical and Cultural",
"Fairness_Equality_and_Rights": "Fairness, Equality and Rights",
"Law_and_Justice_System": "Law and Justice System",
"Crime_and_Punishment": "Crime and Punishment",
"Security_Defense_and_Well_being": "Security, Defense and Well-being",
"Health_and_Safety": "Health and Safety",
"Politics": "Politics",
"International_Relations": "International Relations",
"news_genre": "Genre",
"news_genre_tooltip": "Determine whether the text is most likely to be an opinion piece, objective news reporting, or satire.",
"Opinionated_News": "Opinionated News",
"Reporting": "Objective reporting",
"Satire": "Satire",
"persuasion_techniques": "Persuasion Techniques",
"persuasion_techniques_tooltip": "Identify the persuasion techniques of the extracted text. This service annotates particular sentences within the text that use these techniques. A total of 23 different techniques are considered.",
"Appeal_to_Authority": "Appeal to Authority",
"Appeal_to_Popularity": "Appeal to Popularity",
"Appeal_to_values": "Appeal to values",
"Appeal_to_fear/prejudice": "Appeal to fear/prejudice",
"Flag_Waving": "Flag Waving",
"Causal_oversimplification": "Causal oversimplification",
"False_dilemma_or_no_choice": "False dilemma or no choice",
"Consequential_oversimplification": "Consequential oversimplification",
"Straw_man": "Straw man",
"Red_herring": "Red herring",
"Whataboutism": "Whataboutism",
"Slogans": "Slogans",
"Appeal_to_time": "Appeal to time",
"Conversation_killer": "Conversation killer",
"Loaded_Language": "Loaded language",
"Repetition": "Repetition",
"Exaggeration_or_minimisation": "Exaggeration or minimisation",
"Obfuscation_vagueness_or_confusion": "Obfuscation - vagueness or confusion",
"Name_calling_or_labeling": "Name calling or labeling",
"Doubt": "Doubt",
"Guilt_by_association": "Guilt by association",
"Appeal_to_Hypocrisy": "Appeal to Hypocrisy",
"Questioning_the_reputation": "Questioning the reputation",
"detected_techniques": "Detected techniques",
"no_detected_categories": "No detected categories",
"subjectivity": "Subjectivity",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,15 @@ import FileCopyOutlined from "@mui/icons-material/FileCopy";
import { useNavigate } from "react-router-dom";
import { getLanguageName } from "../../../Shared/Utils/languageUtils";

const renderEntityKeys = (entities) => {
// tidy array into readable string
let entitiesString = Object.keys(entities)
.toString()
.replace("Important_Sentence", "")
.replaceAll(",", ", ")
.replaceAll("_", " ")
.trim();

// remove beginning and last hanging commas
if (entitiesString.slice(0, 2) === ", ") {
entitiesString = entitiesString.substring(2, entitiesString.length);
}
if (entitiesString.slice(-1) === ",") {
entitiesString = entitiesString.substring(0, entitiesString.length - 1);
}

return entitiesString;
const renderEntityKeys = (entities, keyword) => {
// translate array into readable string
let translatedEntities = [];
Object.keys(entities).map((entity, index) =>
entity != "Important_Sentence"
? translatedEntities.push(keyword(entity))
: null,
);
return translatedEntities.join("; ");
};

const round = (number, decimalPlaces) => {
Expand Down Expand Up @@ -428,7 +419,8 @@ const AssistantCredSignals = () => {
<Typography
sx={{ color: "text.secondary", align: "start" }}
>
{renderEntityKeys(newsFramingResult.entities)}
{console.log("top=", newsFramingResult.entities)}
{renderEntityKeys(newsFramingResult.entities, keyword)}
</Typography>
)}
</Grid>
Expand Down Expand Up @@ -501,7 +493,8 @@ const AssistantCredSignals = () => {
<Typography
sx={{ color: "text.secondary", align: "start" }}
>
{renderEntityKeys(newsGenreResult.entities)}
{console.log("gen=", newsGenreResult)}
{renderEntityKeys(newsGenreResult.entities, keyword)}
</Typography>
)}
</Grid>
Expand Down Expand Up @@ -587,7 +580,8 @@ const AssistantCredSignals = () => {
<Typography
sx={{ color: "text.secondary", align: "start" }}
>
{renderEntityKeys(persuasionResult.entities)}
{console.log("per=", persuasionResult.entities)}
{renderEntityKeys(persuasionResult.entities, keyword)}
</Typography>
)}
{persuasionDone &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export default function AssistantTextClassification({
thresholdHigh={configs.confidenceThresholdHigh}
rgbLow={configs.confidenceRgbLow}
rgbHigh={configs.confidenceRgbHigh}
keyword={keyword}
/>
{filteredSentences.length > 0 ? (
<FormControlLabel
Expand Down Expand Up @@ -189,6 +190,7 @@ export function CategoriesList({
thresholdHigh,
rgbLow,
rgbHigh,
keyword,
}) {
if (categories.length < 1) return <p>{noCategoriesText}</p>;

Expand Down Expand Up @@ -217,7 +219,7 @@ export function CategoriesList({
color: textColour,
}}
>
<ListItemText primary={category.replaceAll("_", " ")} />
<ListItemText primary={keyword(category)} />
</ListItem>,
);
index++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ export default function AssistantTextSpanClassification({
noCategoriesText={keyword("no_detected_categories")}
allCategoriesLabel={allCategoriesLabel}
onCategoryChange={handleCategorySelect}
keyword={keyword}
/>
</CardContent>
</Card>
Expand All @@ -299,6 +300,7 @@ export function CategoriesListToggle({
noCategoriesText,
allCategoriesLabel,
onCategoryChange = () => {},
keyword,
}) {
if (categories.length < 1) return <p>{noCategoriesText}</p>;

Expand Down Expand Up @@ -345,7 +347,7 @@ export function CategoriesListToggle({
let textColour = "white";
if (bgLuminance > 0.7) textColour = "black";

const itemText = category.replaceAll("_", " ");
const itemText = keyword(category);
const itemChip = (
<Chip color="primary" label={categories[category].length} />
);
Expand Down

0 comments on commit 97c5987

Please sign in to comment.