|
import gradio as gr |
|
import spacy |
|
import networkx as nx |
|
|
|
|
|
nlp = spacy.load("en_core_web_sm") |
|
G_unreliable = nx.read_graphml('knowledge_graph.graphml') |
|
G_reliable = nx.read_graphml('knowledge_graph_G1.graphml') |
|
|
|
def analyze_misinformation(sentence): |
|
misinformation, corrections = analyze_misinformation(sentence, nlp, G_unreliable, G_reliable) |
|
return {"Misinformation": misinformation, "Corrections": corrections if corrections else "No corrections needed"} |
|
|
|
interface = gr.Interface(fn=analyze_misinformation, |
|
inputs="text", |
|
outputs=["json"], |
|
title="Misinformation Detection Demo", |
|
description="Detects whether a sentence is likely to contain misinformation.") |
|
|
|
if __name__ == "__main__": |
|
interface.launch() |
|
|