kleinay commited on
Commit
1637d4b
β€’
1 Parent(s): 549392b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -23,17 +23,16 @@ links = """<p style='text-align: center'>
23
  def call(sentence, detection_threshold):
24
 
25
  outputs = pipeline([sentence], nominalization_detection_threshold=detection_threshold)[0]
26
- def pretty_qadisc_qas(pred_info) -> List[str]:
27
- if not pred_info: return []
28
  return [f"{qa['question']} --- {qa['answer']}"
29
- for qa in pred_info if qa is not None]
30
  def pretty_qasrl_qas(pred_info) -> List[str]:
31
  if not pred_info or not pred_info['QAs']: return []
32
  return [f"{qa['question']} --- {';'.join(qa['answers'])}"
33
  for qa in pred_info['QAs'] if qa is not None]
34
-
35
- qasrl_qas = pretty_qasrl_qas(outputs['qasrl'])
36
- qanom_qas = pretty_qasrl_qas(outputs['qanom'])
37
  qadisc_qas= pretty_qadisc_qas(outputs['qadiscourse'])
38
  all_qas = ['QASRL:'] + qasrl_qas + ['\nQANom:'] + qanom_qas + ['\nQADiscourse:'] + qadisc_qas
39
  if not qasrl_qas + qanom_qas + qadisc_qas:
 
23
  def call(sentence, detection_threshold):
24
 
25
  outputs = pipeline([sentence], nominalization_detection_threshold=detection_threshold)[0]
26
+ def pretty_qadisc_qas(qa_infos) -> List[str]:
27
+ if not qa_infos: return []
28
  return [f"{qa['question']} --- {qa['answer']}"
29
+ for qa in qa_infos if qa is not None]
30
  def pretty_qasrl_qas(pred_info) -> List[str]:
31
  if not pred_info or not pred_info['QAs']: return []
32
  return [f"{qa['question']} --- {';'.join(qa['answers'])}"
33
  for qa in pred_info['QAs'] if qa is not None]
34
+ qasrl_qas = [qa for pred_info in outputs['qasrl'] for qa in pretty_qasrl_qas(pred_info)]
35
+ qanom_qas = [qa for pred_info in outputs['qanom'] for qa in pretty_qasrl_qas(pred_info)]
 
36
  qadisc_qas= pretty_qadisc_qas(outputs['qadiscourse'])
37
  all_qas = ['QASRL:'] + qasrl_qas + ['\nQANom:'] + qanom_qas + ['\nQADiscourse:'] + qadisc_qas
38
  if not qasrl_qas + qanom_qas + qadisc_qas: