Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding credibility signals feature #562

Merged
merged 39 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3f2597e
Adding credibility signals feature
rosannamilner Jul 23, 2024
405e575
counting categories in wrapfunc change
rosannamilner Jul 23, 2024
d4bc942
Subjectivty confidence colour blue
rosannamilner Jul 24, 2024
f0bf706
refactoring pertech code
rosannamilner Jul 24, 2024
cedfadb
refactor for correct persuasion techniques
rosannamilner Jul 29, 2024
41d26e4
added/removed comments
rosannamilner Jul 29, 2024
eda948f
updated tooltip text
rosannamilner Jul 30, 2024
c2be123
remove console.log
rosannamilner Jul 30, 2024
6915331
fixes for persuasion techniques
rosannamilner Jul 30, 2024
5a15f26
fixes for subjectivity
rosannamilner Jul 30, 2024
596ed86
edited keyword for semantic search
rosannamilner Jul 30, 2024
0360b0f
changed mgt.pred to use keyword
rosannamilner Aug 5, 2024
50153f3
Adding credibility signals feature
rosannamilner Aug 5, 2024
11760b6
Update assistantUtils.jsx
rosannamilner Aug 5, 2024
335fcfa
Update assistantUtils.jsx
rosannamilner Aug 5, 2024
7ef056e
added retries for subjectivity service
rosannamilner Aug 5, 2024
18238ff
Update AssistantTextSpanClassification.jsx
rosannamilner Aug 6, 2024
b6dace8
remove importance value
rosannamilner Aug 6, 2024
2be7cd6
edits for PR
rosannamilner Aug 6, 2024
dcbfedc
changes requested
rosannamilner Aug 6, 2024
e1934cb
removed HpDetails
rosannamilner Aug 6, 2024
d7d3160
Merge branch 'beta-master' into assistant/credibility-signals
rosannamilner Aug 6, 2024
86febec
added code for when no persuasion techniques returned
rosannamilner Aug 7, 2024
d30eb98
Merge branch 'assistant/credibility-signals' of github.com:AFP-Medial…
rosannamilner Aug 7, 2024
58f28b8
changed typography and bug in subjectivity
rosannamilner Aug 12, 2024
8ddbca6
Merge branch 'beta-master' into assistant/credibility-signals
rosannamilner Aug 12, 2024
4e32d11
fixed prevfactcheck auto searching
rosannamilner Aug 13, 2024
7e2c787
changing align to start in typography
rosannamilner Aug 13, 2024
97c5987
added translations for all genres, topics and persuasion
rosannamilner Aug 13, 2024
1e544f4
corrected Assistant.json
rosannamilner Aug 14, 2024
0e5e636
offline translations
rosannamilner Aug 14, 2024
2023bb4
offline translations
rosannamilner Aug 14, 2024
4610d1f
fixed child needs key react error
rosannamilner Aug 14, 2024
ccc8ba5
changed typography component to div
rosannamilner Aug 19, 2024
85e62cb
fixed MUI span error
rosannamilner Aug 20, 2024
89b7df1
fixed unique key error in AssistantTestResult
rosannamilner Aug 20, 2024
a66fdfd
fixed more unique key errors
rosannamilner Aug 20, 2024
24aa84e
fix a unique key error for persuasion
rosannamilner Aug 21, 2024
fed1d7b
fixed issue with no subjectivite sentences detected
rosannamilner Aug 21, 2024
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
47 changes: 46 additions & 1 deletion public/locales/en/components/NavItems/tools/Assistant.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,50 @@
"extracted_urls_url_domain_analysis": "Extracted URLs with URL Domain Analysis",
"extracted_urls_url_domain_analysis_failed": "Extracted URLs with URL Domain Analysis has failed.",
"extracted_urls_tooltip": "<b>What is this?</b></br>For every URL extracted from the original URL, we run either the domain (if this is a non social media URL) or the account (if this is a social media URL) against our URL domain analysis service. The results of this check are shown here.</br></br><b>What can I do with these?</b></br> The domain analysis service intends to collect information about a domain/account from multiple sources. From here, we intend to inform the user whether any of the sources we collect from hold information on the domain/account of the URL entered. The result is split into three types: <ul><li><strong>Warning:</strong> domain listed by source which explicitly lists potentially untrustworthy domains </li><li><strong>Fact checker:</strong> domain listed by source which explicitly lists fact checkers</li><li><strong>Mentions:</strong> domain listed by source which lists a mix of trustworthy and untrustworthy domains</li></ul> Since this is information collected from multiple sources, we have given the source we have taken the details from and if provided, any evidence the source itself has given so users can check the validity of claims made about a domain. For more information on sources and data collection, see <a href=\"https://gatenlp.github.io/domain-analysis-lists/\" target=\"_blank\" rel=\"noopener noreferrer\">this page</a>",
"embedding_not_supported":"The Assistant could not display this video content."
"embedding_not_supported":"The Assistant could not display this video content.",
"assistant_video_download_action": "Download video",
"assistant_video_download_action_description": "Click here to download the video, to your machine. The download video can then be used in the assistant to access a wider range of video analysis services.",
"credibility_signals": "Credibility Signals",
"credibility_signals_tooltip": "<b>What is this?</b></br>This section displays various credibility signals derived by applying AI classifiers to the extracted text of a given page.</br></br><b>What can I do with these?</b></br>The results of these credibility signals give a detailed overview of the extracted text which allows the reader to decide how credible or reliable the source is. For more information on these signals, please see <a href=\"https://gatenlp.github.io/we-verify-app-assistant/supported-tools\" target=\"_blank\">this page</a>.",
"importance_tooltip": "The background of highlighted sentences varies depending on the detection algorithm's rating of its importance.",
"confidence_tooltip_technique": "The background of the detected techniques varies depending on the detection algorithm's confidence.",
"confidence_tooltip_sentence": "The background of highlighted sentences varies depending on the detection algorithm's confidence.",
"highlight_important_sentence": "Highlight important sentences",
"low_importance": "Low importance",
"high_importance": "High importance",
"low_confidence": "Low confidence",
"high_confidence": "High confidence",
"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.",
"news_genre": "Genre",
"news_genre_tooltip": "Determine whether the text is most likely to be an opinion piece, objective news reporting, or 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.",
"detected_techniques": "Detected techniques",
"no_detected_categories": "No detected categories",
"subjectivity": "Subjectivity",
"subjectivity_tooltip": "Identify the subjective sentences of the extracted text.",
"subjective_sentences_detected": "Subjective sentences detected",
"none_detected": "None detected",
"previous_fact_checks": "Previous Fact-Checks",
"previous_fact_checks_tooltip": "The Fact Check Semantic Search tool identifies whether the extracted text has previously been detected in a fact check database. It displays the most recent matches, up to a maximum of 5. This tool is currently only accessible to beta users.",
"more_details": "For more details see",
"semantic_search_title": "Fact Check Semantic Search",
"failed_to_load": "Failed to load",
"previous_fact_checks_found": "Top 5 previous fact-checks found",
"login_required": "Please log in as a beta user to see results",
"reanalyse_url": "Please reanalyse URL to see results",
"semantic_search_result_claim": "Claim:",
"semantic_search_result_title": "Title:",
"semantic_search_result_translated_from": "Translated from",
"semantic_search_result_see_original": "See original",
"semantic_search_result_english_translation": "Show English Translation",
"semantic_search_rating": "Rating:",
"machine_generated_text": "Machine Generated Text",
"machine_generated_text_tooltip": "Determine whether the extracted text has been written by human or machine. This tool is currently only accessible to beta users.",
"highly_likely_human": "Highly likely human written with score ",
"likely_human": "Likely human written with score ",
"likely_machine": "Likely machine generated with score ",
"highly_likely_machine": "Highly likely machine generated with score "
}
19 changes: 17 additions & 2 deletions src/components/NavItems/Assistant/Assistant.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import AssistantSCResults from "./AssistantScrapeResults/AssistantSCResults";
import AssistantTextResult from "./AssistantScrapeResults/AssistantTextResult";
import AssistantUrlSelected from "./AssistantUrlSelected";
import AssistantWarnings from "./AssistantScrapeResults/AssistantWarnings";
import AssistantCredSignals from "./AssistantScrapeResults/AssistantCredibilitySignals";

import {
cleanAssistantState,
Expand Down Expand Up @@ -79,6 +80,13 @@ const Assistant = () => {
(state) => state.assistant.dbkfMediaMatchFail,
);
const neFailState = useSelector((state) => state.assistant.neFail);
const newsFramingFailState = useSelector(
(state) => state.assistant.newsFramingFail,
);
const newsGenreFailState = useSelector(
(state) => state.assistant.newsGenreFail,
);
// const mtFailState = useSelector(state => state.assistant.mtFail)

//local state
const [formInput, setFormInput] = useState(inputUrl);
Expand Down Expand Up @@ -163,7 +171,9 @@ const Assistant = () => {
{scFailState ||
dbkfTextFailState ||
dbkfMediaFailState ||
neFailState ? (
neFailState ||
newsFramingFailState ||
newsGenreFailState ? (
<Grid item xs>
<AssistantCheckStatus />
</Grid>
Expand Down Expand Up @@ -233,12 +243,17 @@ const Assistant = () => {
<AssistantLinkResult />
</Grid>
) : null}

{text ? (
<Grid item xs={12}>
<AssistantCredSignals />
</Grid>
) : null}
</Grid>
</Card>
</Grid>
</Grid>
</div>
);
};

export default Assistant;
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,172 @@ export default function assistantApiCalls() {
return result.data;
};

const callOcrScriptService = async () => {
const result = await axios.get(assistantEndpoint + "gcloud/ocr-scripts");
return result.data;
const MAX_NUM_RETRIES = 3;

/**
* Calls an async function that throws an exception when it fails, will retry for numMaxRetries
* @param numMaxRetries Number of times the function will be retried
* @param asyncFunc The async function to call
* @param errorFunc Called when asyncFunc throws an error when there are additional retries
* @returns {Promise<*>} Output of asyncFunc
*/
async function callAsyncWithNumRetries(
numMaxRetries,
asyncFunc,
errorFunc = null,
) {
for (let retryCount = 0; retryCount < numMaxRetries; retryCount++) {
try {
return await asyncFunc();
} catch (e) {
if (retryCount + 1 >= MAX_NUM_RETRIES) {
throw e;
} else {
if (errorFunc) errorFunc(retryCount, e);
}
}
}
}

const callNewsFramingService = async (text) => {
return await callAsyncWithNumRetries(
MAX_NUM_RETRIES,
async () => {
const result = await axios.post(
assistantEndpoint + "gcloud/news-framing-clfr",
{ text: text },
);
return result.data;
},
(numTries) => {
console.log(
"Could not connect to news framing service, tries " +
(numTries + 1) +
"/" +
MAX_NUM_RETRIES,
);
},
);
};

const callNewsGenreService = async (text) => {
return await callAsyncWithNumRetries(
MAX_NUM_RETRIES,
async () => {
const result = await axios.post(
assistantEndpoint + "gcloud/news-genre-clfr",
{ text: text },
);
return result.data;
},
(numTries) => {
console.log(
"Could not connect to news genre service, tries " +
(numTries + 1) +
"/" +
MAX_NUM_RETRIES,
);
},
);
};

const callPersuasionService = async (text) => {
return await callAsyncWithNumRetries(
MAX_NUM_RETRIES,
async () => {
const result = await axios.post(
assistantEndpoint + "gcloud/persuasion-span-clfr",
{ text: text },
);
return result.data;
},
(numTries) => {
console.log(
"Could not connect to persuasion service, tries " +
(numTries + 1) +
"/" +
MAX_NUM_RETRIES,
);
},
);
};

const callSubjectivityService = async (text) => {
return await callAsyncWithNumRetries(
MAX_NUM_RETRIES,
async () => {
const result = await axios.post(assistantEndpoint + "dw/subjectivity", {
content: text,
});
return result.data;
},
(numTries) => {
console.log(
"Could not connect to previous fact checks service, tries " +
(numTries + 1) +
"/" +
MAX_NUM_RETRIES,
);
},
);
};

const callPrevFactChecksService = async (text) => {
return await callAsyncWithNumRetries(
MAX_NUM_RETRIES,
async () => {
const result = await axios.get(
assistantEndpoint +
"kinit/prev-fact-checks" +
"?text=" +
encodeURIComponent(text), // max URL length is 2048 characters
);
return result.data;
},
(numTries) => {
console.log(
"Could not connect to previous fact checks service, tries " +
(numTries + 1) +
"/" +
MAX_NUM_RETRIES,
);
},
);
};

const callMachineGeneratedTextService = async (text) => {
return await callAsyncWithNumRetries(
MAX_NUM_RETRIES,
async () => {
const result = await axios.get(
assistantEndpoint +
"kinit/machine-generated-text" +
"?text=" +
encodeURIComponent(text), // max URL length is 2048 characters
);
return result.data;
},
(numTries) => {
console.log(
"Could not connect to machine generated text service, tries " +
(numTries + 1) +
"/" +
MAX_NUM_RETRIES,
);
},
);
};

return {
callAssistantScraper,
callSourceCredibilityService,
callNamedEntityService,
callOcrService,
callOcrScriptService,
callNewsFramingService,
callNewsGenreService,
callPersuasionService,
callSubjectivityService,
callPrevFactChecksService,
callMachineGeneratedTextService,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,29 @@ const AssistantCheckStatus = () => {
const neTitle = keyword("ne_title");
const neFailState = useSelector((state) => state.assistant.neFail);

const newsFramingTitle = "news topic";
const newsFramingFailState = useSelector(
(state) => state.assistant.newsFramingFail
);

const newsGenreTitle = "news genre";
const newsGenreFailState = useSelector(
(state) => state.assistant.newsGenreFail
);

const persuasionTitle = "persuasion";
const persuasionFailState = useSelector(
(state) => state.assistant.persuasionFail
);

const failStates = [
{ title: scTitle, failed: scFailState },
{ title: dbkfMediaTitle, failed: dbkfMediaFailState },
{ title: dbkfTextTitle, failed: dbkfTextFailState },
{ title: neTitle, failed: neFailState },
{ title: newsFramingTitle, failed: newsFramingFailState },
{ title: newsGenreTitle, failed: newsGenreFailState },
{ title: persuasionTitle, failed: persuasionFailState },
];

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ const ExtractedSourceCredibilityDBKFDialog = ({
? sourceCredibilityResults.map((value, key) => (
<Accordion key={key}>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
{sourceCredibilityResults[
key
].credibilityScope.includes("/") ? (
{value.credibilityScope.includes("/") ? (
<Typography color={trafficLightColor}>
{` ${keyword("this")}`}
{getUrlTypeFromCredScope(
Expand All @@ -151,15 +149,11 @@ const ExtractedSourceCredibilityDBKFDialog = ({
"source_credibility_warning_account",
)} ${" "}${value.credibilitySource}`}
</Typography>
) : sourceCredibilityResults[key]
.credibilityScope ? (
) : value.credibilityScope ? (
<Typography color={trafficLightColor}>
{` ${keyword(
"source_cred_popup_header_domain",
)} ${
sourceCredibilityResults[key]
.credibilitySource
} `}
)} ${value.credibilitySource} `}
</Typography>
) : null}
</AccordionSummary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ const SourceCredibilityResult = (props) => {
{value.credibilityScope.includes("/") ? (
<Typography>
{` ${keyword("this")}`}
{/* {inputUrlType
? capitaliseFirstLetter(inputUrlType)
: null} */}
{getUrlTypeFromCredScope(value.credibilityScope)}
{` ${keyword(
"source_credibility_warning_account",
Expand Down
Loading