AamerAkhter commited on
Commit
9b77e1f
·
verified ·
1 Parent(s): 8f68250

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from sentence_transformers import SentenceTransformer, util
3
+
4
+ # Load the model
5
+ model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
6
+
7
+ # Define the function to check plagiarism
8
+ def check_plagiarism(student_text, reference_text):
9
+ embeddings = model.encode([student_text, reference_text], convert_to_tensor=True)
10
+ similarity = util.cos_sim(embeddings[0], embeddings[1]).item()
11
+ return f"Similarity Score: {similarity:.2f}"
12
+
13
+ # Create the Gradio interface
14
+ iface = gr.Interface(
15
+ fn=check_plagiarism,
16
+ inputs=["text", "text"],
17
+ outputs="text",
18
+ title="Plagiarism Checker",
19
+ description="Enter a student submission and a reference text to compare similarity. Higher scores indicate higher similarity (possible plagiarism)."
20
+ )
21
+
22
+ # Launch the app
23
+ iface.launch()