IsakNordgren commited on
Commit
a674005
1 Parent(s): 0efbb5e

2 examples for demo

Browse files
.gitignore CHANGED
@@ -1 +1,2 @@
1
  .env
 
 
1
  .env
2
+ Examples
__pycache__/page.cpython-310.pyc ADDED
Binary file (856 Bytes). View file
 
__pycache__/summarize.cpython-310.pyc CHANGED
Binary files a/__pycache__/summarize.cpython-310.pyc and b/__pycache__/summarize.cpython-310.pyc differ
 
app.py CHANGED
@@ -3,7 +3,7 @@ from summarize import Summarizer
3
 
4
  def main():
5
  st.title("Text Extractor and Summarizer")
6
-
7
  summarizer = Summarizer(model = "groq")
8
  summarizer.run_app()
9
 
 
3
 
4
  def main():
5
  st.title("Text Extractor and Summarizer")
6
+
7
  summarizer = Summarizer(model = "groq")
8
  summarizer.run_app()
9
 
page.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from summarize import Summarizer
3
+ import pdfplumber
4
+
5
+ def createDemoPage(path):
6
+ with st.spinner("Summarizing text..."):
7
+ summarizer = Summarizer(model = "groq")
8
+ text = readpdf("Examples/Kris.pdf")
9
+ summary = summarizer.summarize(text)
10
+
11
+ st.subheader("Summary")
12
+ st.write(summary)
13
+
14
+ st.subheader("Extracted Text")
15
+ st.write(text)
16
+
17
+ def readpdf(path):
18
+ text = ""
19
+ with pdfplumber.open(path) as pdf_file:
20
+ for page in pdf_file.pages:
21
+ text += page.extract_text()
22
+ return text
pages/Hyresavi.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from summarize import Summarizer
3
+ import pdfplumber
4
+ import page
5
+
6
+ def main():
7
+ st.title("Text Extractor and Summarizer")
8
+
9
+ st.subheader("(Detta är ett exempel på hur en hyresavi sammanfattas)")
10
+ page.createDemoPage("Examples/Hyresavi.pdf")
11
+
12
+ main()
pages/Om krisen eller kriget kommer.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from summarize import Summarizer
3
+ import pdfplumber
4
+ import page
5
+
6
+ def main():
7
+ st.title("Text Extractor and Summarizer")
8
+
9
+ st.subheader("(Detta är ett exempel på hur MSBs broschyr \"Om krisen eller kriget kommer\" sammanfattas)")
10
+ page.createDemoPage("Examples/Kris.pdf")
11
+
12
+ main()