com3dian commited on
Commit
8d4620d
·
1 Parent(s): 6c813f8

update file reader

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -1,9 +1,16 @@
1
  import streamlit as st
2
  import pandas as pd
3
  import numpy as np
 
 
4
 
5
- st.title('Paper2Slides')
 
 
 
 
6
 
 
7
 
8
  st.subheader('Upload paper in pdf format')
9
  uploaded_file = st.file_uploader("Choose a file")
@@ -11,3 +18,14 @@ if uploaded_file is not None:
11
  st.write(uploaded_file.name)
12
  bytes_data = uploaded_file.getvalue()
13
  st.write(len(bytes_data), "bytes")
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import pandas as pd
3
  import numpy as np
4
+ import os
5
+ import grobidmonkey
6
 
7
+ def save_uploaded_file(uploaded_file):
8
+ file_path = os.path.join("uploads", uploaded_file.name)
9
+ with open(file_path, "wb") as f:
10
+ f.write(uploaded_file.getbuffer())
11
+ return file_path # Return the file path as a string
12
 
13
+ st.title('Paper2Slides')
14
 
15
  st.subheader('Upload paper in pdf format')
16
  uploaded_file = st.file_uploader("Choose a file")
 
18
  st.write(uploaded_file.name)
19
  bytes_data = uploaded_file.getvalue()
20
  st.write(len(bytes_data), "bytes")
21
+ saved_file_path = save_uploaded_file(uploaded_file)
22
+
23
+
24
+ monkeyReader = reader.MonkeyReader('monkey')
25
+ outline = monkeyReader.readOutline(saved_file_path)
26
+
27
+ for pre, fill, node in outline:
28
+ st.write("%s%s" % (pre, node.name))
29
+
30
+ # read paper content
31
+ essay = monkeyReader.readEssay(saved_file_path)