GBRKNIGHT commited on
Commit
e8ce01d
·
verified ·
1 Parent(s): 95481f2

Create gradio.py

Browse files
Files changed (1) hide show
  1. gradio.py +21 -0
gradio.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import spacy
3
+ import networkx as nx
4
+
5
+ # Load your NLP model and graphs
6
+ nlp = spacy.load("en_core_web_sm")
7
+ G_unreliable = nx.read_graphml('knowledge_graph.graphml')
8
+ G_reliable = nx.read_graphml('knowledge_graph_G1.graphml')
9
+
10
+ def analyze_misinformation(sentence):
11
+ misinformation, corrections = analyze_misinformation(sentence, nlp, G_unreliable, G_reliable)
12
+ return {"Misinformation": misinformation, "Corrections": corrections if corrections else "No corrections needed"}
13
+
14
+ interface = gr.Interface(fn=analyze_misinformation,
15
+ inputs="text",
16
+ outputs=["json"],
17
+ title="Misinformation Detection Demo",
18
+ description="Detects whether a sentence is likely to contain misinformation.")
19
+
20
+ if __name__ == "__main__":
21
+ interface.launch()