Skip to main content

QA based Semantics

Project description


Logo

Parser for Question-Answer based Semantics

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?)

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Paul Roit - @paul_roit

Project Link: https://github.com/plroit/qasem_parser

(back to top)

Acknowledgments

(back to top)

Project details


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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qasem_parser-1.1.16-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file qasem_parser-1.1.16.tar.gz.

File metadata

  • Download URL: qasem_parser-1.1.16.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for qasem_parser-1.1.16.tar.gz
Algorithm Hash digest
SHA256 26af76636328563bf7976817657627bf666c3d5a8349e7debcf3da0039cae5a3
MD5 e344783e7cbcef26554dc67461ce9181
BLAKE2b-256 f8a5a2ace6737d34ff05bfaa7aa2fdbb329269b64ef13e84d2d86d17f8bbd363

See more details on using hashes here.

File details

Details for the file qasem_parser-1.1.16-py3-none-any.whl.

File metadata

  • Download URL: qasem_parser-1.1.16-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for qasem_parser-1.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 20982af8994cc1d11a559ed399c52c8454209e06dd121145a9193365a7583735
MD5 1ccd723f48688288ee59cd459b20fce0
BLAKE2b-256 edd453e925d7df686076e361ac4c2e09c343aef7fc157377b87a2d240b7d24cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page