shivanis14 commited on
Commit
5dcb046
1 Parent(s): edf2a16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -298,8 +298,14 @@ def get_files_with_ingredient_info(ingredient, N=1):
298
  file_paths = []
299
  #Find embedding for title of all files
300
  global embeddings_titles
 
 
 
 
 
 
301
  #Apply cosine similarity between embedding of ingredient name and title of all files
302
- file_paths_abs, titles = find_relevant_file_paths(ingredient, embeddings_titles)
303
  #Fine top N titles that are the most similar to the ingredient's name
304
  #Find file names for those titles
305
  if len(file_paths_abs) == 0:
@@ -308,7 +314,7 @@ def get_files_with_ingredient_info(ingredient, N=1):
308
  for file_path in file_paths_abs:
309
  file_paths.append(f"articles/{file_path}")
310
 
311
- print(f"Titles are {titles}")
312
 
313
  return file_paths
314
 
 
298
  file_paths = []
299
  #Find embedding for title of all files
300
  global embeddings_titles
301
+
302
+ with open('titles.txt', 'r') as file:
303
+ lines = file.readlines()
304
+
305
+ titles = [line.strip() for line in lines]
306
+
307
  #Apply cosine similarity between embedding of ingredient name and title of all files
308
+ file_paths_abs, file_titles = find_relevant_file_paths(ingredient, embeddings_titles, titles, N=N)
309
  #Fine top N titles that are the most similar to the ingredient's name
310
  #Find file names for those titles
311
  if len(file_paths_abs) == 0:
 
314
  for file_path in file_paths_abs:
315
  file_paths.append(f"articles/{file_path}")
316
 
317
+ print(f"Titles are {file_titles}")
318
 
319
  return file_paths
320