Roland Ding commited on
Commit
bebb801
·
1 Parent(s): a6d0043

9.9.24.73 updated the add_article method

Browse files

While running the app from huggingface hosting, since the file has a
different path naming convention, the filename was not properly extracted
due to linux system has a different path annotation than windows.

added filename extraction logic for selecting the filename from the path
string for both windows and linux systems.

modified: features.py

Files changed (1) hide show
  1. features.py +6 -1
features.py CHANGED
@@ -339,7 +339,12 @@ def add_article(domain,file,add_to_s3=True, add_to_local=True, file_object=True)
339
  else:
340
  # extract the content from the pdf file
341
  content, _ = read_pdf(file)
342
- filename = file.name.split("\\")[-1]
 
 
 
 
 
343
 
344
  # upload the article to s3
345
  pdf_obj = open(file.name, 'rb')
 
339
  else:
340
  # extract the content from the pdf file
341
  content, _ = read_pdf(file)
342
+ if "\\" in file.name:
343
+ filename = file.name.split("\\")[-1]
344
+ elif "/" in file.name:
345
+ filename = file.name.split("/")[-1]
346
+ else:
347
+ filename = file.name
348
 
349
  # upload the article to s3
350
  pdf_obj = open(file.name, 'rb')