Update app.py
Browse files
app.py
CHANGED
@@ -19,17 +19,17 @@ except ValueError as e:
|
|
19 |
classifier_loaded = False
|
20 |
|
21 |
# Streamlit app title
|
22 |
-
st.title("Question
|
23 |
|
24 |
# Input text for summarization and classification
|
25 |
-
text_input = st.text_area("Enter long question to
|
26 |
|
27 |
if st.button("Process"):
|
28 |
if summarizer_loaded and classifier_loaded and text_input:
|
29 |
try:
|
30 |
# Perform text summarization
|
31 |
summary = summarizer(text_input, max_length=130, min_length=30, do_sample=False)
|
32 |
-
summarized_text = summary[0]['
|
33 |
except Exception as e:
|
34 |
st.error(f"Error during summarization: {e}")
|
35 |
summarized_text = ""
|
@@ -40,7 +40,7 @@ if st.button("Process"):
|
|
40 |
results = classifier(summarized_text)[0]
|
41 |
# Find the category with the highest score
|
42 |
max_score = max(results, key=lambda x: x['score'])
|
43 |
-
st.write("
|
44 |
st.write("Category:", max_score['label'])
|
45 |
st.write("Score:", max_score['score'])
|
46 |
except Exception as e:
|
|
|
19 |
classifier_loaded = False
|
20 |
|
21 |
# Streamlit app title
|
22 |
+
st.title("Question Rephrase and Classification")
|
23 |
|
24 |
# Input text for summarization and classification
|
25 |
+
text_input = st.text_area("Enter long question to rephrase and classify:", "")
|
26 |
|
27 |
if st.button("Process"):
|
28 |
if summarizer_loaded and classifier_loaded and text_input:
|
29 |
try:
|
30 |
# Perform text summarization
|
31 |
summary = summarizer(text_input, max_length=130, min_length=30, do_sample=False)
|
32 |
+
summarized_text = summary[0]['rephrase_text']
|
33 |
except Exception as e:
|
34 |
st.error(f"Error during summarization: {e}")
|
35 |
summarized_text = ""
|
|
|
40 |
results = classifier(summarized_text)[0]
|
41 |
# Find the category with the highest score
|
42 |
max_score = max(results, key=lambda x: x['score'])
|
43 |
+
st.write("Rephrased Text:", summarized_text)
|
44 |
st.write("Category:", max_score['label'])
|
45 |
st.write("Score:", max_score['score'])
|
46 |
except Exception as e:
|