Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,7 +30,7 @@ def main():
|
|
| 30 |
st.title("Terms of Service Summarizer")
|
| 31 |
|
| 32 |
# Layout: 3 columns
|
| 33 |
-
col1, col2, col3 = st.columns([1,
|
| 34 |
|
| 35 |
# Left column: Radio buttons for summarizer choice
|
| 36 |
with col1:
|
|
@@ -45,7 +45,7 @@ def main():
|
|
| 45 |
"Keyphrase Extraction: Keyphrase extraction is similar to keyword extraction but focuses on identifying multi-word phrases or expressions that are significant in the text using the Rake algorithm."
|
| 46 |
|
| 47 |
radio_selection = st.radio("Choose type of summarizer:", radio_options, help=help_text)
|
| 48 |
-
|
| 49 |
# Middle column: Text input and File uploader
|
| 50 |
with col2:
|
| 51 |
user_input = st.text_area("Enter your text here:")
|
|
@@ -109,12 +109,27 @@ def main():
|
|
| 109 |
if radio_selection == "Keyphrase Extraction (RAKE)":
|
| 110 |
summary = extract_sentences_with_obligations(file_content)
|
| 111 |
st.session_state.summary = summary
|
| 112 |
-
|
| 113 |
# Right column: Displaying text after pressing 'Summarize'
|
| 114 |
with col3:
|
| 115 |
st.write("Summary:")
|
| 116 |
if 'summary' in st.session_state:
|
| 117 |
st.write(st.session_state.summary)
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
if __name__ == "__main__":
|
| 120 |
main()
|
|
|
|
| 30 |
st.title("Terms of Service Summarizer")
|
| 31 |
|
| 32 |
# Layout: 3 columns
|
| 33 |
+
col1, col2, col3 = st.columns([1, 2, 3], gap="large")
|
| 34 |
|
| 35 |
# Left column: Radio buttons for summarizer choice
|
| 36 |
with col1:
|
|
|
|
| 45 |
"Keyphrase Extraction: Keyphrase extraction is similar to keyword extraction but focuses on identifying multi-word phrases or expressions that are significant in the text using the Rake algorithm."
|
| 46 |
|
| 47 |
radio_selection = st.radio("Choose type of summarizer:", radio_options, help=help_text)
|
| 48 |
+
|
| 49 |
# Middle column: Text input and File uploader
|
| 50 |
with col2:
|
| 51 |
user_input = st.text_area("Enter your text here:")
|
|
|
|
| 109 |
if radio_selection == "Keyphrase Extraction (RAKE)":
|
| 110 |
summary = extract_sentences_with_obligations(file_content)
|
| 111 |
st.session_state.summary = summary
|
| 112 |
+
|
| 113 |
# Right column: Displaying text after pressing 'Summarize'
|
| 114 |
with col3:
|
| 115 |
st.write("Summary:")
|
| 116 |
if 'summary' in st.session_state:
|
| 117 |
st.write(st.session_state.summary)
|
| 118 |
|
| 119 |
+
# Check if a reference summary is available
|
| 120 |
+
if tos_selection_index is not None and 'summary' in dataset['train'][tos_selection_index]:
|
| 121 |
+
# Fetch the reference summary
|
| 122 |
+
reference_summary = data['train'][tos_selection_index]['summary']
|
| 123 |
+
|
| 124 |
+
# Calculate ROUGE scores
|
| 125 |
+
rouge = Rouge()
|
| 126 |
+
scores = rouge.get_scores(st.session_state.summary, reference_summary)
|
| 127 |
+
|
| 128 |
+
# Display ROUGE scores
|
| 129 |
+
st.write("ROUGE Scores:")
|
| 130 |
+
st.write(f"ROUGE-1: {scores[0]['rouge-1']['f']:.4f}")
|
| 131 |
+
st.write(f"ROUGE-2: {scores[0]['rouge-2']['f']:.4f}")
|
| 132 |
+
st.write(f"ROUGE-L: {scores[0]['rouge-l']['f']:.4f}")
|
| 133 |
+
|
| 134 |
if __name__ == "__main__":
|
| 135 |
main()
|