MCQ-Generator / main.py
DevBM's picture
Upload 15 files
97d9e12 verified
raw
history blame
1.38 kB
import streamlit as st
from pprint import pprint
import subprocess
cmd = ["python", "-m", "spacy", "download", "en_core_web_sm"]
subprocess.run(cmd)
from spacy.cli import download
from Questgen import main
from spacy.cli import download
# download('en_core_web_sm')
st.set_page_config(
page_title='Questgen',
page_icon= ':fire:',
)
st.title(body='Question Generator')
input_text = st.text_area(
label='Enter text from which questions are to be generated',
value = 'Sachin Tendulkar is the best batsman in the history of cricket. Sachin is from Mumbai. Sachin has two children.'
)
qg = main.QGen()
payload = {
'input_text' : input_text
}
output = qg.predict_mcq(payload=payload)
st.header(body='*Generated Questions are:*', divider='orange')
for question in output['questions']:
st.subheader(body=f":orange[Q{question['id']}:] {question['question_statement']}", divider='blue')
st.markdown(f"A: {question['answer']}")
c = 0
for option in question['options']:
# st.markdown(f"{c}")
c+=1
if c==1:
st.markdown(f"B: {option}")
elif c==2:
st.markdown(f"C: {option}")
elif c==3:
st.markdown(f"D: {option}")
# st.write(f"{question['question_statement']}")
if st.toggle(label='Show Total Output'):
st.write(output)