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

adding 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_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,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['ayat'].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_hadith.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('hadith_combined.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['text'].iloc[idx], dist) for idx, dist in zip(indices[0], distances[0])]
29
  return similar_sentences
30
 
31
  def search_interface(query):
embeddings_quran.pkl → embeddings_hadith.pkl RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:06857222e1efcae222c6e50269f15df7daa4bc892c49d43d24e3187342cfdb6c
3
- size 9277603
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d5e670ba9df7be27831614831af8a57e8e3f13ff632093c946196cdcf24b7357
3
+ size 31225507
hadith_combined.csv ADDED
The diff for this file is too large to render. See raw diff
 
quran_data.csv DELETED
The diff for this file is too large to render. See raw diff