dantedgp commited on
Commit
2701c34
·
1 Parent(s): fca4e51

Multiple sentence support

Browse files
Files changed (2) hide show
  1. app.py +16 -3
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
  from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
3
 
4
  # Instantiate the model
@@ -16,9 +17,21 @@ def generate_questions(txt):
16
 
17
  st.set_page_config(page_title='AI Quiz Generator')
18
  st.title('AI Quiz Generator')
19
- txt_input = st.text_area('Enter your text', '', height=200)
 
 
 
 
 
 
20
  generate_button = st.button("Generate Questions")
21
 
22
  if generate_button:
23
- questions = generate_questions(txt_input)
24
- st.write(questions)
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import nltk
3
  from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
4
 
5
  # Instantiate the model
 
17
 
18
  st.set_page_config(page_title='AI Quiz Generator')
19
  st.title('AI Quiz Generator')
20
+ st.subtitle('It generates questions from your notes. How cool is that?')
21
+ text_input = st.text_area(
22
+ 'Enter your text',
23
+ value='Algae cells can be used to synthesize lipids for the production of biofuels and foods.',
24
+ height=200
25
+ )
26
+
27
  generate_button = st.button("Generate Questions")
28
 
29
  if generate_button:
30
+ if text_input != '':
31
+ sentences = nltk.sent_tokenize(text_input)
32
+ for sentence in sentences:
33
+ question = generate_questions(text_input)
34
+ st.write(question)
35
+ else:
36
+ st.warning('Please enter some text.')
37
+
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  transformers
2
- torch
 
 
1
  transformers
2
+ torch
3
+ nltk