Spaces:
Sleeping
Sleeping
Arko Banik
commited on
Commit
·
1277726
1
Parent(s):
0e5fe33
changed indexing into categories
Browse files
app.py
CHANGED
@@ -187,9 +187,9 @@ def get_sorted_cosine_similarity(embeddings_metadata):
|
|
187 |
##########################################
|
188 |
## TODO: Get embeddings for categories ###
|
189 |
##########################################
|
190 |
-
category_embeddings =
|
191 |
for cat in categories:
|
192 |
-
category_embeddings
|
193 |
|
194 |
else:
|
195 |
model_name = embeddings_metadata["model_name"]
|
@@ -211,8 +211,8 @@ def get_sorted_cosine_similarity(embeddings_metadata):
|
|
211 |
# TODO: Compute cosine similarity between input sentence and categories
|
212 |
# TODO: Update category embeddings if category not found
|
213 |
##########################################
|
214 |
-
cat_embed = category_embeddings[index]
|
215 |
cat = categories[index]
|
|
|
216 |
# Calc cosine sim
|
217 |
cat_scores.append((cat, np.dot(input_embedding,cat_embed)))
|
218 |
# Store doc_id and score as a tuple
|
|
|
187 |
##########################################
|
188 |
## TODO: Get embeddings for categories ###
|
189 |
##########################################
|
190 |
+
category_embeddings = {}
|
191 |
for cat in categories:
|
192 |
+
category_embeddings[cat] = get_glove_embeddings(cat, word_index_dict, embeddings, model_type)
|
193 |
|
194 |
else:
|
195 |
model_name = embeddings_metadata["model_name"]
|
|
|
211 |
# TODO: Compute cosine similarity between input sentence and categories
|
212 |
# TODO: Update category embeddings if category not found
|
213 |
##########################################
|
|
|
214 |
cat = categories[index]
|
215 |
+
cat_embed = category_embeddings[cat]
|
216 |
# Calc cosine sim
|
217 |
cat_scores.append((cat, np.dot(input_embedding,cat_embed)))
|
218 |
# Store doc_id and score as a tuple
|