Spaces:
Runtime error
Runtime error
OmarElSayed
commited on
Commit
•
2c6575f
1
Parent(s):
b27d547
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import pandas as pd
|
|
2 |
import spacy
|
3 |
import gradio as gr
|
4 |
import re
|
5 |
-
|
6 |
|
7 |
dataset = pd.read_excel('Dataset-Verse-by-Verse.xlsx')
|
8 |
dataset.rename(columns={'ArabicText': 'text'}, inplace=True)
|
@@ -35,8 +35,8 @@ def get_similar_sentences(text):
|
|
35 |
similarity_score = ref_sentence.similarity(nlp(doc))
|
36 |
similar_sentence = doc
|
37 |
surah_name = dataset['SurahNameArabic'][i]
|
38 |
-
ayah_no = dataset['AyahNo'][i]
|
39 |
-
surah_no = dataset['SurahNo'][i]
|
40 |
similar_sentences.append({
|
41 |
"similar_sentence": similar_sentence,
|
42 |
"similarity_score": similarity_score,
|
@@ -46,7 +46,7 @@ def get_similar_sentences(text):
|
|
46 |
})
|
47 |
similar_sentences.sort(key=lambda x: x['similarity_score'], reverse=True)
|
48 |
top_10 = similar_sentences[:10]
|
49 |
-
return top_10
|
50 |
|
51 |
text_input = gr.inputs.Textbox(lines = 1 , label = "Enter a Quran Verse" )
|
52 |
|
@@ -57,5 +57,5 @@ examples = ['الحمدلله رب العالمين',
|
|
57 |
'ونادى أصحاب الجنة أصحاب النار أن قد وجدنا ما وعدنا ربنا حقا فهل وجدتم ما وعد ربكم حقا ۖ قالوا نعم ۚ فأذن مؤذن بينهم أن لعنة الله على الظالمين'
|
58 |
]
|
59 |
|
60 |
-
intf = gr.Interface(fn = get_similar_sentences , inputs = text_input , outputs =
|
61 |
intf.launch(debug = True)
|
|
|
2 |
import spacy
|
3 |
import gradio as gr
|
4 |
import re
|
5 |
+
import json
|
6 |
|
7 |
dataset = pd.read_excel('Dataset-Verse-by-Verse.xlsx')
|
8 |
dataset.rename(columns={'ArabicText': 'text'}, inplace=True)
|
|
|
35 |
similarity_score = ref_sentence.similarity(nlp(doc))
|
36 |
similar_sentence = doc
|
37 |
surah_name = dataset['SurahNameArabic'][i]
|
38 |
+
ayah_no = int(dataset['AyahNo'][i])
|
39 |
+
surah_no = int(dataset['SurahNo'][i])
|
40 |
similar_sentences.append({
|
41 |
"similar_sentence": similar_sentence,
|
42 |
"similarity_score": similarity_score,
|
|
|
46 |
})
|
47 |
similar_sentences.sort(key=lambda x: x['similarity_score'], reverse=True)
|
48 |
top_10 = similar_sentences[:10]
|
49 |
+
return json.dumps(top_10)
|
50 |
|
51 |
text_input = gr.inputs.Textbox(lines = 1 , label = "Enter a Quran Verse" )
|
52 |
|
|
|
57 |
'ونادى أصحاب الجنة أصحاب النار أن قد وجدنا ما وعدنا ربنا حقا فهل وجدتم ما وعد ربكم حقا ۖ قالوا نعم ۚ فأذن مؤذن بينهم أن لعنة الله على الظالمين'
|
58 |
]
|
59 |
|
60 |
+
intf = gr.Interface(fn = get_similar_sentences , inputs = text_input , outputs = "json", examples=examples )
|
61 |
intf.launch(debug = True)
|