Spaces:
Sleeping
Sleeping
adding new files
Browse files- app.py +3 -3
- embeddings.pkl → embeddings_quran.pkl +2 -2
- quran_data.csv +0 -0
- quran_hadith.csv +0 -3
app.py
CHANGED
@@ -5,14 +5,14 @@ from sklearn.neighbors import NearestNeighbors
|
|
5 |
import gradio as gr
|
6 |
|
7 |
# Load the embeddings from the file
|
8 |
-
with open('
|
9 |
embeddings = pickle.load(f)
|
10 |
|
11 |
# Initialize the Nearest Neighbors model with cosine similarity
|
12 |
nbrs = NearestNeighbors(n_neighbors=10, metric='cosine').fit(embeddings)
|
13 |
|
14 |
# Load the dataset
|
15 |
-
df = pd.read_csv('
|
16 |
|
17 |
# Initialize the SentenceTransformer model
|
18 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
@@ -25,7 +25,7 @@ def semantic_search(query, model, embeddings, nbrs):
|
|
25 |
distances, indices = nbrs.kneighbors([query_embedding])
|
26 |
|
27 |
# Return the k most similar sentences and their distances
|
28 |
-
similar_sentences = [(df['
|
29 |
return similar_sentences
|
30 |
|
31 |
def search_interface(query):
|
|
|
5 |
import gradio as gr
|
6 |
|
7 |
# Load the embeddings from the file
|
8 |
+
with open('embeddings_quran.pkl', 'rb') as f:
|
9 |
embeddings = pickle.load(f)
|
10 |
|
11 |
# Initialize the Nearest Neighbors model with cosine similarity
|
12 |
nbrs = NearestNeighbors(n_neighbors=10, metric='cosine').fit(embeddings)
|
13 |
|
14 |
# Load the dataset
|
15 |
+
df = pd.read_csv('quran_data.csv', delimiter='\t')
|
16 |
|
17 |
# Initialize the SentenceTransformer model
|
18 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
|
|
25 |
distances, indices = nbrs.kneighbors([query_embedding])
|
26 |
|
27 |
# Return the k most similar sentences and their distances
|
28 |
+
similar_sentences = [(df['ayat'].iloc[idx], dist) for idx, dist in zip(indices[0], distances[0])]
|
29 |
return similar_sentences
|
30 |
|
31 |
def search_interface(query):
|
embeddings.pkl → embeddings_quran.pkl
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:06857222e1efcae222c6e50269f15df7daa4bc892c49d43d24e3187342cfdb6c
|
3 |
+
size 9277603
|
quran_data.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
quran_hadith.csv
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:6beddedddf73d2e8327e284a0eeed55820a246e6f99e19445c812027b5744cc5
|
3 |
-
size 10748559
|
|
|
|
|
|
|
|