QA based Semantics
Project description
About The Project
Reimplementation of the QA-SEM pipeline with re-trained joint argument parser model
Getting Started
Installation
pip install qasem_parser
Usage
from typing import List
from qasem_parser import QasemParser, QasemFrame
arg_parser_path = "cattana/flan-t5-large-qasem-joint-tokenized"
parser = QasemParser.from_pretrained(arg_parser_path)
sentences = [
"The fox jumped over the fence.",
"Back in May, a signal consistent with that of a radio beacon was detected in the area, but nothing turned up that helped with the search."
]
# frames is a list of lists, with one sublist per sentence such that len(frames) == len(sentences)
# frames[i] is a sublist of the semantic frames that occur within sentence[i]
frames: List[List[QasemFrame]] = parser(sentences)
print(frames[1][0])
# detect-v: Back in May (when: when was something detected?)
# | a signal consistent with that of a radio beacon (R1: what was detected?)
# | in the area (where: where was something detected?)
# The parser also respects original tokenization
# if the input is a batch of tokenized sentences
pretokenized_sentences = [
"Unfortunately , extensive property damage is bound to occur even with the best preparation .".split(),
"Afghanistan to attend the summit after following the election in June , "
"but the ongoing audit of votes has made this impossible .".split()
]
frames = parser(pretokenized_sentences)
for frames_per_sent in frames:
# NOTE: frames_per_sent might be empty if no predicate
# is detected in the sentence.
for frame in frames_per_sent:
print(frame)
print()
#
# bind-v: extensive property damage (R0: what is bound to do something?)
# | occur even with the best preparation (R1: what is something bound to do?)
# occur-v: extensive property damage (R0: what is occurring?)
# | even with the best preparation (how: how is something occurring?)
# damage-n: extensive property (R1: what is damaged?)
# prepare-n: extensive property damage (R1: what is prepared?)
#
# call-v: Plans (R0: what called for something?)
# | the new President , or President-elect , of Afghanistan to attend the summit after following the election in June (R1: what did something call for?)
# attend-v: the new President , or President-elect , of Afghanistan (R0: who attends something?)
# | the summit (R1: what does someone attend?)
# | after following the election in June (when: when does someone attend something?)
# follow-v: the election (R1: what was followed?)
# | in June (when: when was something followed?)
# make-v: the ongoing audit of votes (R0: what made something?) | this impossible (R1: what did something make?)
# plan-n: Plans (R0: what planned something?)
# | the new President , or President-elect , of Afghanistan to attend the summit after following the election in June , but the ongoing audit of votes has made this impossible (R1: what did something plan?)
# elect-n: the new President , or President-elect , of Afghanistan (R1: what was elected?)
# | in June (when: when was something elected?)
# audit-n: votes (R1: what was audited?)
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Paul Roit - @paul_roit
Project Link: https://github.com/plroit/qasem_parser
Acknowledgments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
qasem_parser-1.1.16.tar.gz
(16.5 kB
view hashes)
Built Distribution
Close
Hashes for qasem_parser-1.1.16-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20982af8994cc1d11a559ed399c52c8454209e06dd121145a9193365a7583735 |
|
MD5 | 1ccd723f48688288ee59cd459b20fce0 |
|
BLAKE2b-256 | edd453e925d7df686076e361ac4c2e09c343aef7fc157377b87a2d240b7d24cc |