com3dian commited on
Commit
48102c5
·
verified ·
1 Parent(s): 3d2f753

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -36,12 +36,13 @@ with col2:
36
  option = st.selectbox(
37
  'Select parsing method.',
38
  ('monkey', 'x2d', 'lxml'))
39
- range_values = st.slider(
40
- 'Select a range of values',
41
- min_value=0,
42
- max_value=100,
43
- value=(25, 75)
44
- )
 
45
 
46
  summ_text = None
47
 
@@ -73,6 +74,7 @@ if (uploaded_file is not None) and (not 'generation_done' in st.session_state):
73
 
74
  with st.status("Generating slides..."):
75
  summarizor = pipeline("summarization", model=summ_model_path, device = device)
 
76
  summ_text = summarizor(document.segmentation['text'], max_length=100, min_length=10, do_sample=False)
77
  summ_text = [text['summary_text'] for text in summ_text]
78
 
@@ -81,14 +83,15 @@ if (uploaded_file is not None) and (not 'generation_done' in st.session_state):
81
  if (summ_text is not None) or ('summ_text' in st.session_state):
82
 
83
  # Function to render HTML content
84
- def format(text_list):
85
  format_list = []
86
- for text in text_list:
 
87
  # Split text by periods
88
  sentences = text.split('.')
89
  # Create HTML list items
90
  list_items = "".join([f"- {sentence.strip()}.\n" for sentence in sentences if sentence.strip()])
91
- format_list.append(list_items)
92
  return format_list
93
 
94
  # Initialize session state for page index and text
@@ -96,7 +99,7 @@ if (summ_text is not None) or ('summ_text' in st.session_state):
96
  st.session_state.page_index = 0
97
 
98
  if 'summ_text' not in st.session_state:
99
- st.session_state.summ_text = format(summ_text)
100
 
101
  if 'current_text' not in st.session_state:
102
  st.session_state.current_text = st.session_state.summ_text[st.session_state.page_index]
 
36
  option = st.selectbox(
37
  'Select parsing method.',
38
  ('monkey', 'x2d', 'lxml'))
39
+
40
+ range_values = st.slider(
41
+ 'Select a range of values',
42
+ min_value=0,
43
+ max_value=100,
44
+ value=(0, 25)
45
+ )
46
 
47
  summ_text = None
48
 
 
74
 
75
  with st.status("Generating slides..."):
76
  summarizor = pipeline("summarization", model=summ_model_path, device = device)
77
+ title_list = document.segmentation['key']
78
  summ_text = summarizor(document.segmentation['text'], max_length=100, min_length=10, do_sample=False)
79
  summ_text = [text['summary_text'] for text in summ_text]
80
 
 
83
  if (summ_text is not None) or ('summ_text' in st.session_state):
84
 
85
  # Function to render HTML content
86
+ def format(title_list, text_list):
87
  format_list = []
88
+ for index, text in enumerate(text_list):
89
+ title = "##" + title_list[index] + "\n"
90
  # Split text by periods
91
  sentences = text.split('.')
92
  # Create HTML list items
93
  list_items = "".join([f"- {sentence.strip()}.\n" for sentence in sentences if sentence.strip()])
94
+ format_list.append(title + list_items)
95
  return format_list
96
 
97
  # Initialize session state for page index and text
 
99
  st.session_state.page_index = 0
100
 
101
  if 'summ_text' not in st.session_state:
102
+ st.session_state.summ_text = format(summ_text, title_list)
103
 
104
  if 'current_text' not in st.session_state:
105
  st.session_state.current_text = st.session_state.summ_text[st.session_state.page_index]