@@ -300,20 +300,23 @@ def generate_html(output_path: str, docs: Documents, search_word: str, search_mo
300
300
tempfile_path = tempfile_path + "/table"
301
301
table .df [0 ].str .strip ('.!? \n \t ' )
302
302
# perform fuzzy search over all columns
303
+ found = False
303
304
for i in range (0 , table .shape [1 ]):
304
- for x in process .extract (search_word , table .df [i ].astype (str ).values .tolist (),
305
- scorer = fuzz .partial_ratio ):
306
- if x [1 ] > 80 :
307
- table .to_html (tempfile_path , classes = "responsive-table" , index = False )
308
- with codecs .open (tempfile_path , 'r' ) as table_file :
309
- # replace \n in table to fix formatting
310
- tab = re .sub (r'\\n' , '<br>' , table_file .read ())
311
- if not header_printed :
312
- with tag ('h2' ):
313
- text ("Found in document with location: " + str (document .path ))
314
- doc .asis (tab )
315
- os .remove (tempfile_path )
316
- break
305
+ if not found :
306
+ for x in process .extract (search_word , table .df [i ].astype (str ).values .tolist (),
307
+ scorer = fuzz .partial_ratio ):
308
+ if x [1 ] > 80 :
309
+ table .to_html (tempfile_path , classes = "responsive-table" , index = False )
310
+ with codecs .open (tempfile_path , 'r' ) as table_file :
311
+ # replace \n in table to fix formatting
312
+ tab = re .sub (r'\\n' , '<br>' , table_file .read ())
313
+ if not header_printed :
314
+ with tag ('h2' ):
315
+ text ("Found in document with location: " + str (document .path ))
316
+ doc .asis (tab )
317
+ os .remove (tempfile_path )
318
+ found = True
319
+ break
317
320
318
321
# write HTML to file
319
322
# check if output path is a directory
0 commit comments