bhlewis commited on
Commit
8b7ba6b
1 Parent(s): 0ca2cde

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -11,7 +11,12 @@ from collections import Counter
11
  import spacy
12
 
13
  # Load Spacy model for advanced NLP
14
- nlp = spacy.load("en_core_web_sm")
 
 
 
 
 
15
 
16
  def load_data():
17
  try:
@@ -79,7 +84,7 @@ def hybrid_search(query, top_k=5):
79
  query_embedding = query_embedding / np.linalg.norm(query_embedding)
80
 
81
  # Perform semantic similarity search
82
- semantic_distances, semantic_indices = index.search(np.array([query_embedding]), top_k * 2)
83
 
84
  # Perform TF-IDF based search
85
  query_tfidf = tfidf_vectorizer.transform([query])
 
11
  import spacy
12
 
13
  # Load Spacy model for advanced NLP
14
+ try:
15
+ nlp = spacy.load("en_core_web_sm")
16
+ except IOError:
17
+ print("Downloading spacy model...")
18
+ spacy.cli.download("en_core_web_sm")
19
+ nlp = spacy.load("en_core_web_sm")
20
 
21
  def load_data():
22
  try:
 
84
  query_embedding = query_embedding / np.linalg.norm(query_embedding)
85
 
86
  # Perform semantic similarity search
87
+ semantic_distances, semantic_indices = index.search(np.array([query_embedding]).astype('float32'), top_k * 2)
88
 
89
  # Perform TF-IDF based search
90
  query_tfidf = tfidf_vectorizer.transform([query])