mhdhrubo commited on
Commit
85afc2b
1 Parent(s): da490a8

adding new files

Browse files
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('embeddings.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_hadith.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['text'].iloc[idx], dist) for idx, dist in zip(indices[0], distances[0])]
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:bea0ad0ae5e5cf9a73dad7706c32f651e6596cd5b025a5abd440ca5bde7e006a
3
- size 40502947
 
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