Davidsamuel101 commited on
Commit
e0427a6
1 Parent(s): 25e174d

Remove leading spaces

Browse files
requirements.txt CHANGED
@@ -2,5 +2,5 @@ transformers
2
  mdutils==1.6.0
3
  pymupdf==1.21.1
4
  torch
5
- gradio==3.25.0
6
  sentencepiece
2
  mdutils==1.6.0
3
  pymupdf==1.21.1
4
  torch
5
+ gradio==3.27.0
6
  sentencepiece
src/__pycache__/summarizer.cpython-38.pyc CHANGED
Binary files a/src/__pycache__/summarizer.cpython-38.pyc and b/src/__pycache__/summarizer.cpython-38.pyc differ
src/app.py CHANGED
@@ -6,7 +6,7 @@ def inference(document):
6
  slide_content = summarizer.extract_text(document)
7
  summarized_slides = summarizer(slide_content)
8
  markdown = summarizer.convert2markdown(summarized_slides)
9
- print(f"Markdown File Name: {markdown.file_name}")
10
  return markdown.file_name
11
 
12
  with gr.Blocks() as demo:
6
  slide_content = summarizer.extract_text(document)
7
  summarized_slides = summarizer(slide_content)
8
  markdown = summarizer.convert2markdown(summarized_slides)
9
+ summarizer.remove_leading_empty_lines(markdown.file_name)
10
  return markdown.file_name
11
 
12
  with gr.Blocks() as demo:
src/summarizer.py CHANGED
@@ -60,6 +60,23 @@ class Summarizer():
60
  mdFile.new_line(f"{content}\n")
61
  markdown = mdFile.create_md_file()
62
  return markdown
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
 
 
 
64
 
65
 
60
  mdFile.new_line(f"{content}\n")
61
  markdown = mdFile.create_md_file()
62
  return markdown
63
+
64
+ def remove_leading_empty_lines(self, file_path) -> None:
65
+ with open(file_path, 'r') as file:
66
+ lines = file.readlines()
67
+
68
+ non_empty_lines = []
69
+ found_first_word = False
70
+
71
+ for line in lines:
72
+ stripped_line = line.strip()
73
+ if stripped_line and not found_first_word:
74
+ found_first_word = True
75
+ if found_first_word or stripped_line:
76
+ non_empty_lines.append(line)
77
 
78
+ with open(file_path, 'w') as file:
79
+ file.writelines(non_empty_lines)
80
+ return
81
 
82