Spaces:
Runtime error
Runtime error
EmreYY20
commited on
Commit
•
432c28d
1
Parent(s):
b4ed5a3
add keyword extraction
Browse files- app.py +7 -1
- keyword_extraction.py +18 -0
app.py
CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
|
|
2 |
import PyPDF2
|
3 |
from extractive_model import summarize_with_textrank
|
4 |
from abstractive_model import summarize_with_bart
|
|
|
5 |
#from blanc import BlancHelp
|
6 |
|
7 |
# Set page to wide mode
|
@@ -24,7 +25,7 @@ def main():
|
|
24 |
|
25 |
# Left column: Radio buttons for summarizer choice
|
26 |
with col1:
|
27 |
-
radio_options = ['Abstractive', 'Extractive']
|
28 |
radio_selection = st.radio("Choose type of summarizer:", radio_options)
|
29 |
|
30 |
# Middle column: Text input and File uploader
|
@@ -55,6 +56,11 @@ def main():
|
|
55 |
summary = summarize_with_bart(file_content)
|
56 |
st.session_state.summary = summary
|
57 |
|
|
|
|
|
|
|
|
|
|
|
58 |
# Right column: Displaying text after pressing 'Summarize'
|
59 |
with col3:
|
60 |
st.write("Summary:")
|
|
|
2 |
import PyPDF2
|
3 |
from extractive_model import summarize_with_textrank
|
4 |
from abstractive_model import summarize_with_bart
|
5 |
+
from keyword_extraction import extract_keywords
|
6 |
#from blanc import BlancHelp
|
7 |
|
8 |
# Set page to wide mode
|
|
|
25 |
|
26 |
# Left column: Radio buttons for summarizer choice
|
27 |
with col1:
|
28 |
+
radio_options = ['Abstractive', 'Extractive', 'Keyword Extraction']
|
29 |
radio_selection = st.radio("Choose type of summarizer:", radio_options)
|
30 |
|
31 |
# Middle column: Text input and File uploader
|
|
|
56 |
summary = summarize_with_bart(file_content)
|
57 |
st.session_state.summary = summary
|
58 |
|
59 |
+
# Perform extractive summarization
|
60 |
+
if radio_selection == "Keyword Extraction":
|
61 |
+
summary = extract_keywords(file_content)
|
62 |
+
st.session_state.summary = summary
|
63 |
+
|
64 |
# Right column: Displaying text after pressing 'Summarize'
|
65 |
with col3:
|
66 |
st.write("Summary:")
|
keyword_extraction.py
CHANGED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import nltk
|
2 |
+
from rake_nltk import Rake
|
3 |
+
|
4 |
+
# Download NLTK data (if not already downloaded)
|
5 |
+
nltk.download('punkt')
|
6 |
+
|
7 |
+
def extract_keywords(text):
|
8 |
+
# Initialize Rake with stopwords set to None (to keep all words)
|
9 |
+
rake = Rake()
|
10 |
+
|
11 |
+
# Extract keywords from the input text
|
12 |
+
rake.extract_keywords_from_text(text)
|
13 |
+
|
14 |
+
# Get the ranked keywords
|
15 |
+
ranked_keywords = rake.get_ranked_phrases()
|
16 |
+
|
17 |
+
return ranked_keywords
|
18 |
+
|