Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,49 +1,50 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
from pprint import pprint
|
| 3 |
-
import subprocess
|
| 4 |
-
cmd = ["python", "-m", "spacy", "download", "en_core_web_sm"]
|
| 5 |
-
subprocess.run(cmd)
|
| 6 |
-
from spacy.cli import download
|
| 7 |
-
from Questgen import main
|
| 8 |
-
from spacy.cli import download
|
| 9 |
-
|
| 10 |
-
# download('en_core_web_sm')
|
| 11 |
-
|
| 12 |
-
st.set_page_config(
|
| 13 |
-
page_title='Questgen',
|
| 14 |
-
page_icon= ':fire:',
|
| 15 |
-
)
|
| 16 |
-
|
| 17 |
-
st.title(body='Question Generator')
|
| 18 |
-
|
| 19 |
-
input_text = st.text_area(
|
| 20 |
-
label='Enter text from which questions are to be generated',
|
| 21 |
-
value = 'Sachin Tendulkar is the best batsman in the history of cricket. Sachin is from Mumbai. Sachin has two children.'
|
| 22 |
-
)
|
| 23 |
-
|
| 24 |
-
qg = main.QGen()
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
st.
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
c
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from pprint import pprint
|
| 3 |
+
import subprocess
|
| 4 |
+
cmd = ["python", "-m", "spacy", "download", "en_core_web_sm"]
|
| 5 |
+
subprocess.run(cmd)
|
| 6 |
+
from spacy.cli import download
|
| 7 |
+
from Questgen import main, main2
|
| 8 |
+
from spacy.cli import download
|
| 9 |
+
|
| 10 |
+
# download('en_core_web_sm')
|
| 11 |
+
|
| 12 |
+
st.set_page_config(
|
| 13 |
+
page_title='Questgen',
|
| 14 |
+
page_icon= ':fire:',
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
st.title(body='Question Generator')
|
| 18 |
+
|
| 19 |
+
input_text = st.text_area(
|
| 20 |
+
label='Enter text from which questions are to be generated',
|
| 21 |
+
value = 'Sachin Tendulkar is the best batsman in the history of cricket. Sachin is from Mumbai. Sachin has two children.'
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
# qg = main.QGen()
|
| 25 |
+
qg = main2.QGen()
|
| 26 |
+
|
| 27 |
+
payload = {
|
| 28 |
+
'input_text' : input_text
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
output = qg.predict_mcq(payload=payload)
|
| 32 |
+
|
| 33 |
+
st.header(body='*Generated Questions are:*', divider='orange')
|
| 34 |
+
for question in output['questions']:
|
| 35 |
+
st.subheader(body=f":orange[Q{question['id']}:] {question['question_statement']}", divider='blue')
|
| 36 |
+
st.markdown(f"A: {question['answer']}")
|
| 37 |
+
c = 0
|
| 38 |
+
for option in question['options']:
|
| 39 |
+
# st.markdown(f"{c}")
|
| 40 |
+
c+=1
|
| 41 |
+
if c==1:
|
| 42 |
+
st.markdown(f"B: {option}")
|
| 43 |
+
elif c==2:
|
| 44 |
+
st.markdown(f"C: {option}")
|
| 45 |
+
elif c==3:
|
| 46 |
+
st.markdown(f"D: {option}")
|
| 47 |
+
# st.write(f"{question['question_statement']}")
|
| 48 |
+
|
| 49 |
+
if st.toggle(label='Show Total Output'):
|
| 50 |
+
st.write(output)
|