@@ -150,9 +150,9 @@ def insert_word_desc(self, word_name, word_desc):
150150 :param word_name: The name of the word(string).
151151 :param word_desc: The description of the word(string).
152152 """
153-
154- self .log .info (f"Inserting word description: { word_name } - { word_desc } " )
155- self .word_desc .insert_one ({"word_name" : word_name , "word_desc" : word_desc })
153+ if word_desc != None :
154+ self .log .info (f"Inserting word description: { word_name } - { word_desc } " )
155+ self .word_desc .insert_one ({"word_name" : word_name , "word_desc" : word_desc })
156156 def insert_word_location (self , word_name , word_location ):
157157 """Insert word and its location into the NLP database.
158158
@@ -359,6 +359,8 @@ def search_entire_db(self, term):
359359
360360 self .log .info (f"Searching entire database for: { term } " )
361361
362+ final_results = []
363+
362364 for d in self .dbs :
363365 self .log .info (f"===> Database: { d .name } " )
364366 for c in d .list_collection_names ():
@@ -371,12 +373,14 @@ def search_entire_db(self, term):
371373
372374 for key in keys :
373375 self .log .info (f" ===> Key: { c } " )
374- results .append (db_col_search .find ({key : re .compile (rf"\b{ term } \b" , re .IGNORECASE )}))
375- final_results = []
376-
377- for i in results :
378- for j in i :
379- final_results .append (j )
376+ search = db_col_search .find ({key : re .compile (rf"\b{ term } \b" , re .IGNORECASE )})
377+ results .append (search )
378+ try :
379+ a = search .next ()
380+ self .log .info (f" ===> Found: { a } " )
381+ final_results .append (a )
382+ except :
383+ self .log .info (f" ===> Found: None" )
380384
381385 return final_results
382386
0 commit comments