mghareeb32 commited on
Commit
8f94a78
·
1 Parent(s): 3f6a011

Better corpus choice.

Browse files
Files changed (2) hide show
  1. app.css +7 -0
  2. app.py +22 -23
app.css CHANGED
@@ -18,3 +18,10 @@ p, div, input, label, h1, h2, h3, h4, h5, h6 {
18
  background-color: rgba(0, 0, 0, 0);
19
  border: 0px;
20
  }
 
 
 
 
 
 
 
 
18
  background-color: rgba(0, 0, 0, 0);
19
  border: 0px;
20
  }
21
+ [data-baseweb="radio"] div [data-testid="stMarkdownContainer"] {
22
+ padding-right: 8px;
23
+ }
24
+ [data-testid="stPopoverButton"] div {
25
+ margin-left: 0px;
26
+ margin-right: 4px;
27
+ }
app.py CHANGED
@@ -6,20 +6,19 @@ st.markdown(
6
  f"<style>{open('app.css', 'r').read()}</style>",
7
  unsafe_allow_html=True)
8
 
9
- corpus = ""
10
- cols = st.columns([3, 3, 3])
11
- with cols[2]:
12
- op = [""]
13
- op.extend([f"مثال #{i}" for i in range(len(CORPUSES()))])
14
- choice = st.selectbox(
15
- label="",
16
- options=op)
17
- choice_idx = op.index(choice)
18
- if choice_idx > 0: corpus = CORPUSES()[choice_idx-1]
19
- corpus = st.text_area(
20
- label="قطعة القراءة",
21
- placeholder="أدخل نصا",
22
- value=corpus)
23
 
24
  @st.cache_resource
25
  def gen_qa(corpus, qbank_i):
@@ -48,16 +47,17 @@ def answers_toggle():
48
  st.session_state.answers_visible = not answers_visible()
49
 
50
 
51
- with ThreadPoolExecutor(max_workers=32) as executor:
52
- futures = [
53
- executor.submit(gen_qa, corpus, qbank_i)
54
- for qbank_i in qs()
55
- ]
56
- results = [future.result() for future in as_completed(futures)]
57
- print(results)
 
58
 
59
  for qi, qbank_i in enumerate(qs()):
60
- question, answer = gen_qa(corpus, qbank_i)
61
  answer_is_multiline = answer is not None and '\n' in answer
62
  with st.container(border=True):
63
  cols = st.columns([1, 13, 1])
@@ -73,7 +73,6 @@ for qi, qbank_i in enumerate(qs()):
73
  label=f"سؤال {qi+1}",
74
  value=question,
75
  key=f"qq_{qi}",
76
- disabled=True,
77
  )
78
  if answers_visible():
79
  component = st.text_area if answer_is_multiline else st.text_input
 
6
  f"<style>{open('app.css', 'r').read()}</style>",
7
  unsafe_allow_html=True)
8
 
9
+ if 'corpus' not in st.session_state:
10
+ st.session_state.corpus = ""
11
+ cols = st.columns([10, 2])
12
+ with cols[1]:
13
+ with st.popover("أمثلة", use_container_width=True):
14
+ options = [f" مثال {i+1}" for i in range(len(CORPUSES()))]
15
+ example = st.radio("اختر مثالا", options)
16
+ st.session_state.corpus = CORPUSES()[options.index(example)]
17
+ with cols[0]:
18
+ st.session_state.corpus = st.text_area(
19
+ label="قطعة القراءة",
20
+ placeholder="أدخل نصا",
21
+ value=st.session_state.corpus)
 
22
 
23
  @st.cache_resource
24
  def gen_qa(corpus, qbank_i):
 
47
  st.session_state.answers_visible = not answers_visible()
48
 
49
 
50
+ with st.spinner('جاري تحهيز الأسئلة...'):
51
+ with ThreadPoolExecutor(max_workers=32) as executor:
52
+ futures = [
53
+ executor.submit(gen_qa, st.session_state.corpus, qbank_i)
54
+ for qbank_i in qs()
55
+ ]
56
+ results = [future.result() for future in as_completed(futures)]
57
+ print(results)
58
 
59
  for qi, qbank_i in enumerate(qs()):
60
+ question, answer = gen_qa(st.session_state.corpus, qbank_i)
61
  answer_is_multiline = answer is not None and '\n' in answer
62
  with st.container(border=True):
63
  cols = st.columns([1, 13, 1])
 
73
  label=f"سؤال {qi+1}",
74
  value=question,
75
  key=f"qq_{qi}",
 
76
  )
77
  if answers_visible():
78
  component = st.text_area if answer_is_multiline else st.text_input