Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,9 @@ pipeline = QASemEndToEndPipeline()
|
|
8 |
description = f"""This is a demo of the QASem Parsing pipeline. It wraps models of three QA-based semantic tasks, composing a comprehensive semi-structured representation of sentence meaning - covering verbal and nominal semantic role labeling together with discourse relations."""
|
9 |
title="QASem Parsing Demo"
|
10 |
examples = [["Both were shot in the confrontation with police and have been recovering in hospital since the attack .", 0.75],
|
11 |
-
["the construction of the officer 's building was delayed by the lockdown and is expected to continue for at least 10 more months.", 0.
|
|
|
|
|
12 |
["The doctor asked about the progress in Luke 's treatment .", 0.75],
|
13 |
["The Veterinary student was interested in Luke 's treatment of sea animals .", 0.7],
|
14 |
["Some reviewers agreed that the criticism raised by the AC is mostly justified .", 0.6]]
|
@@ -25,11 +27,11 @@ def call(sentence, detection_threshold):
|
|
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']}".lstrip()
|
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'])}".lstrip()
|
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)]
|
|
|
8 |
description = f"""This is a demo of the QASem Parsing pipeline. It wraps models of three QA-based semantic tasks, composing a comprehensive semi-structured representation of sentence meaning - covering verbal and nominal semantic role labeling together with discourse relations."""
|
9 |
title="QASem Parsing Demo"
|
10 |
examples = [["Both were shot in the confrontation with police and have been recovering in hospital since the attack .", 0.75],
|
11 |
+
["the construction of the officer 's building was delayed by the lockdown and is expected to continue for at least 10 more months.", 0.75],
|
12 |
+
["While President Obama expressed condolences regarding the death of Margaret Thatcher upon her death earlier this year , he did not issue an executive order that flags be lowered in her honor .", 0.75],
|
13 |
+
["We made a very clear commitment : if there is any proposal in the next parliament for a transfer of powers to Brussels ( the EU ) we will have an in/out referendum .", 0.75],
|
14 |
["The doctor asked about the progress in Luke 's treatment .", 0.75],
|
15 |
["The Veterinary student was interested in Luke 's treatment of sea animals .", 0.7],
|
16 |
["Some reviewers agreed that the criticism raised by the AC is mostly justified .", 0.6]]
|
|
|
27 |
outputs = pipeline([sentence], nominalization_detection_threshold=detection_threshold)[0]
|
28 |
def pretty_qadisc_qas(qa_infos) -> List[str]:
|
29 |
if not qa_infos: return []
|
30 |
+
return [f"- {qa['question']} --- {qa['answer']}".lstrip()
|
31 |
for qa in qa_infos if qa is not None]
|
32 |
def pretty_qasrl_qas(pred_info) -> List[str]:
|
33 |
if not pred_info or not pred_info['QAs']: return []
|
34 |
+
return [f"- {qa['question']} --- {';'.join(qa['answers'])}".lstrip()
|
35 |
for qa in pred_info['QAs'] if qa is not None]
|
36 |
qasrl_qas = [qa for pred_info in outputs['qasrl'] for qa in pretty_qasrl_qas(pred_info)]
|
37 |
qanom_qas = [qa for pred_info in outputs['qanom'] for qa in pretty_qasrl_qas(pred_info)]
|