DevBM commited on
Commit
dda9416
1 Parent(s): 22d77cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -49
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
- payload = {
27
- 'input_text' : input_text
28
- }
29
-
30
- output = qg.predict_mcq(payload=payload)
31
-
32
- st.header(body='*Generated Questions are:*', divider='orange')
33
- for question in output['questions']:
34
- st.subheader(body=f":orange[Q{question['id']}:] {question['question_statement']}", divider='blue')
35
- st.markdown(f"A: {question['answer']}")
36
- c = 0
37
- for option in question['options']:
38
- # st.markdown(f"{c}")
39
- c+=1
40
- if c==1:
41
- st.markdown(f"B: {option}")
42
- elif c==2:
43
- st.markdown(f"C: {option}")
44
- elif c==3:
45
- st.markdown(f"D: {option}")
46
- # st.write(f"{question['question_statement']}")
47
-
48
- if st.toggle(label='Show Total Output'):
49
- st.write(output)
 
 
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)