Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,13 +16,11 @@ from nltk.tokenize import sent_tokenize
|
|
16 |
|
17 |
# Load spaCy model
|
18 |
nlp = spacy.load("en_core_web_sm")
|
19 |
-
# wiki_wiki = wikipediaapi.Wikipedia('en')
|
20 |
|
21 |
# Initialize Wikipedia API with a user agent
|
22 |
user_agent = 'QGen/1.0 ([email protected])'
|
23 |
wiki_wiki = wikipediaapi.Wikipedia(user_agent= user_agent,language='en')
|
24 |
|
25 |
-
|
26 |
# Load T5 model and tokenizer
|
27 |
model_name = "DevBM/t5-large-squad"
|
28 |
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
@@ -102,7 +100,7 @@ def export_to_pdf(data):
|
|
102 |
pdf.output("questions.pdf")
|
103 |
|
104 |
# Streamlit interface
|
105 |
-
st.title("Question Generator from Text")
|
106 |
text = st.text_area("Enter text here:", value="Joe Biden, the current US president is on a weak wicket going in for his reelection later this November against former President Donald Trump.")
|
107 |
|
108 |
# Customization options
|
@@ -110,7 +108,8 @@ num_beams = st.slider("Select number of beams for question generation", min_valu
|
|
110 |
context_window_size = st.slider("Select context window size (number of sentences before and after)", min_value=1, max_value=5, value=1)
|
111 |
num_questions = st.slider("Select number of questions to generate", min_value=1, max_value=1000, value=5)
|
112 |
question_complexity = st.selectbox("Select question complexity", ["Simple", "Intermediate", "Complex"])
|
113 |
-
|
|
|
114 |
if st.button("Generate Questions"):
|
115 |
if text:
|
116 |
keywords = extract_keywords(text)
|
@@ -132,11 +131,13 @@ if st.button("Generate Questions"):
|
|
132 |
data.append((context, keyword, question))
|
133 |
|
134 |
# Export buttons
|
135 |
-
if st.button("Export to CSV"):
|
|
|
136 |
export_to_csv(data)
|
137 |
st.success("Questions exported to questions.csv")
|
138 |
|
139 |
-
if st.button("Export to PDF"):
|
|
|
140 |
export_to_pdf(data)
|
141 |
st.success("Questions exported to questions.pdf")
|
142 |
else:
|
|
|
16 |
|
17 |
# Load spaCy model
|
18 |
nlp = spacy.load("en_core_web_sm")
|
|
|
19 |
|
20 |
# Initialize Wikipedia API with a user agent
|
21 |
user_agent = 'QGen/1.0 ([email protected])'
|
22 |
wiki_wiki = wikipediaapi.Wikipedia(user_agent= user_agent,language='en')
|
23 |
|
|
|
24 |
# Load T5 model and tokenizer
|
25 |
model_name = "DevBM/t5-large-squad"
|
26 |
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
|
|
100 |
pdf.output("questions.pdf")
|
101 |
|
102 |
# Streamlit interface
|
103 |
+
st.title(":blue[Question Generator from Text]")
|
104 |
text = st.text_area("Enter text here:", value="Joe Biden, the current US president is on a weak wicket going in for his reelection later this November against former President Donald Trump.")
|
105 |
|
106 |
# Customization options
|
|
|
108 |
context_window_size = st.slider("Select context window size (number of sentences before and after)", min_value=1, max_value=5, value=1)
|
109 |
num_questions = st.slider("Select number of questions to generate", min_value=1, max_value=1000, value=5)
|
110 |
question_complexity = st.selectbox("Select question complexity", ["Simple", "Intermediate", "Complex"])
|
111 |
+
downlaod_csv = st.toggle('Download CSV',value=False)
|
112 |
+
download_pdf = st.toggle('Download PDF',value=False)
|
113 |
if st.button("Generate Questions"):
|
114 |
if text:
|
115 |
keywords = extract_keywords(text)
|
|
|
131 |
data.append((context, keyword, question))
|
132 |
|
133 |
# Export buttons
|
134 |
+
# if st.button("Export to CSV"):
|
135 |
+
if downlaod_csv:
|
136 |
export_to_csv(data)
|
137 |
st.success("Questions exported to questions.csv")
|
138 |
|
139 |
+
# if st.button("Export to PDF"):
|
140 |
+
if download_pdf:
|
141 |
export_to_pdf(data)
|
142 |
st.success("Questions exported to questions.pdf")
|
143 |
else:
|