qasem-parser


Nameqasem-parser JSON
Version 1.1.14 PyPI version JSON
download
home_page
SummaryQA based Semantics
upload_time2024-01-31 18:21:42
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT License Copyright (c) 2023 plroit Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords qasem nlp semantics
VCS
bugtrack_url
requirements torch transformers
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 -->
<a name="readme-top"></a>

<!-- PROJECT SHIELDS -->
<!--
*** I'm using markdown "reference style" links for readability.
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
*** See the bottom of this document for the declaration of the reference variables
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
-->



<!-- PROJECT LOGO -->
<br />
<div align="center">
  <a href="https://github.com/plroit/qasem_parser">
    <!-- This image was used originally in the paper: https://aclanthology.org/2021.emnlp-main.778.pdf -->
    <img src="images/logo.svg" alt="Logo">
  </a>

<h3 align="center">Parser for Question-Answer based Semantics</h3>
</div>



<!-- ABOUT THE PROJECT -->
## About The Project

Reimplementation of the [QA-SEM pipeline](https://github.com/kleinay/QASem/) with re-trained joint argument parser model

<!-- GETTING STARTED -->
## Getting Started

### Installation
   ```sh
   pip install qasem_parser
   ```

<!-- USAGE EXAMPLES -->
### Usage
```python
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?)
```

<p align="right">(<a href="#readme-top">back to top</a>)</p>



<!-- ROADMAP 
## Roadmap

- [ ] Feature 1
- [ ] Feature 2
- [ ] Feature 3
    - [ ] Nested Feature
See the [open issues](https://github.com/github_username/repo_name/issues) for a full list of proposed features (and known issues).
-->


<!-- LICENSE -->
## License

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


<!-- CONTACT -->
## Contact

Paul Roit - [@paul_roit](https://twitter.com/paul_roit)

Project Link: [https://github.com/plroit/qasem_parser](https://github.com/plroit/qasem_parser)

<p align="right">(<a href="#readme-top">back to top</a>)</p>



<!-- ACKNOWLEDGMENTS -->
## Acknowledgments

* [Ayal Klein](https://github.com/kleinay)
* [Arie Cattan](https://ariecattan.github.io/)

<p align="right">(<a href="#readme-top">back to top</a>)</p>



<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/github_username/repo_name.svg?style=for-the-badge
[contributors-url]: https://github.com/github_username/repo_name/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/github_username/repo_name.svg?style=for-the-badge
[forks-url]: https://github.com/github_username/repo_name/network/members
[stars-shield]: https://img.shields.io/github/stars/github_username/repo_name.svg?style=for-the-badge
[stars-url]: https://github.com/github_username/repo_name/stargazers
[issues-shield]: https://img.shields.io/github/issues/github_username/repo_name.svg?style=for-the-badge
[issues-url]: https://github.com/github_username/repo_name/issues
[license-shield]: https://img.shields.io/github/license/github_username/repo_name.svg?style=for-the-badge
[license-url]: https://github.com/github_username/repo_name/blob/master/LICENSE.txt


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "qasem-parser",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "qasem,nlp,semantics",
    "author": "",
    "author_email": "Paul Roit <plroit@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/7a/82/abbf8bc2d47c6442f64c945644911edf48ac3871e44fa3138dbc80459543/qasem_parser-1.1.14.tar.gz",
    "platform": null,
    "description": "<!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 -->\r\n<a name=\"readme-top\"></a>\r\n\r\n<!-- PROJECT SHIELDS -->\r\n<!--\r\n*** I'm using markdown \"reference style\" links for readability.\r\n*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).\r\n*** See the bottom of this document for the declaration of the reference variables\r\n*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.\r\n*** https://www.markdownguide.org/basic-syntax/#reference-style-links\r\n-->\r\n\r\n\r\n\r\n<!-- PROJECT LOGO -->\r\n<br />\r\n<div align=\"center\">\r\n  <a href=\"https://github.com/plroit/qasem_parser\">\r\n    <!-- This image was used originally in the paper: https://aclanthology.org/2021.emnlp-main.778.pdf -->\r\n    <img src=\"images/logo.svg\" alt=\"Logo\">\r\n  </a>\r\n\r\n<h3 align=\"center\">Parser for Question-Answer based Semantics</h3>\r\n</div>\r\n\r\n\r\n\r\n<!-- ABOUT THE PROJECT -->\r\n## About The Project\r\n\r\nReimplementation of the [QA-SEM pipeline](https://github.com/kleinay/QASem/) with re-trained joint argument parser model\r\n\r\n<!-- GETTING STARTED -->\r\n## Getting Started\r\n\r\n### Installation\r\n   ```sh\r\n   pip install qasem_parser\r\n   ```\r\n\r\n<!-- USAGE EXAMPLES -->\r\n### Usage\r\n```python\r\nfrom typing import List\r\nfrom qasem_parser import QasemParser, QasemFrame\r\narg_parser_path = \"cattana/flan-t5-large-qasem-joint-tokenized\"\r\nparser = QasemParser.from_pretrained(arg_parser_path)\r\n\r\nsentences = [\r\n    \"The fox jumped over the fence.\",\r\n    \"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.\"\r\n]\r\n# frames is a list of lists, with one sublist per sentence such that len(frames) == len(sentences)  \r\n# frames[i] is a sublist of the semantic frames that occur within sentence[i] \r\nframes: List[List[QasemFrame]] = parser(sentences)\r\nprint(frames[1][0])\r\n# detect-v:  Back in May (when: when was something detected?) \r\n#            | a signal consistent with that of a radio beacon (R1: what was detected?) \r\n#            | in the area (where: where was something detected?) \r\n\r\n# The parser also respects original tokenization\r\n# if the input is a batch of tokenized sentences  \r\npretokenized_sentences = [\r\n    \"Unfortunately , extensive property damage is bound to occur even with the best preparation .\".split(),\r\n    \"Afghanistan to attend the summit after following the election in June , \"\r\n    \"but the ongoing audit of votes has made this impossible .\".split()\r\n]\r\nframes = parser(pretokenized_sentences)\r\n\r\nfor frames_per_sent in frames:\r\n    # NOTE: frames_per_sent might be empty if no predicate \r\n    #       is detected in the sentence.\r\n    for frame in frames_per_sent:\r\n        print(frame)\r\n    print()        \r\n# \r\n# bind-v:  extensive property damage (R0: what is  bound  to do something?) \r\n#           | occur even with the best preparation (R1: what is something bound  to do?)\r\n# occur-v:  extensive property damage (R0: what is occurring?)\r\n#           | even with the best preparation (how: how is something occurring?)\r\n# damage-n:  extensive property (R1: what is damaged?)\r\n# prepare-n:  extensive property damage (R1: what is prepared?)\r\n#\r\n# call-v:  Plans (R0: what   called  for something?)\r\n#           | the new President , or President-elect , of Afghanistan to attend the summit after following the election in June (R1: what did something call for?)\r\n# attend-v:  the new President , or President-elect , of Afghanistan (R0: who attends something?) \r\n#           | the summit (R1: what does someone attend?) \r\n#           | after following the election in June (when: when does someone attend something?)\r\n# follow-v: the election (R1: what was followed?) \r\n#           | in June (when: when was something followed?)\r\n# make-v:  the ongoing audit of votes (R0: what made something?) | this impossible (R1: what did something make?)\r\n# plan-n:  Plans (R0: what planned something?) \r\n#           | 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?)\r\n# elect-n:  the new President , or President-elect , of Afghanistan (R1: what was elected?) \r\n#           | in June (when: when was something elected?)\r\n# audit-n:  votes (R1: what was audited?)\r\n```\r\n\r\n<p align=\"right\">(<a href=\"#readme-top\">back to top</a>)</p>\r\n\r\n\r\n\r\n<!-- ROADMAP \r\n## Roadmap\r\n\r\n- [ ] Feature 1\r\n- [ ] Feature 2\r\n- [ ] Feature 3\r\n    - [ ] Nested Feature\r\nSee the [open issues](https://github.com/github_username/repo_name/issues) for a full list of proposed features (and known issues).\r\n-->\r\n\r\n\r\n<!-- LICENSE -->\r\n## License\r\n\r\nDistributed under the MIT License. See `LICENSE` for more information.\r\n\r\n\r\n<!-- CONTACT -->\r\n## Contact\r\n\r\nPaul Roit - [@paul_roit](https://twitter.com/paul_roit)\r\n\r\nProject Link: [https://github.com/plroit/qasem_parser](https://github.com/plroit/qasem_parser)\r\n\r\n<p align=\"right\">(<a href=\"#readme-top\">back to top</a>)</p>\r\n\r\n\r\n\r\n<!-- ACKNOWLEDGMENTS -->\r\n## Acknowledgments\r\n\r\n* [Ayal Klein](https://github.com/kleinay)\r\n* [Arie Cattan](https://ariecattan.github.io/)\r\n\r\n<p align=\"right\">(<a href=\"#readme-top\">back to top</a>)</p>\r\n\r\n\r\n\r\n<!-- MARKDOWN LINKS & IMAGES -->\r\n<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->\r\n[contributors-shield]: https://img.shields.io/github/contributors/github_username/repo_name.svg?style=for-the-badge\r\n[contributors-url]: https://github.com/github_username/repo_name/graphs/contributors\r\n[forks-shield]: https://img.shields.io/github/forks/github_username/repo_name.svg?style=for-the-badge\r\n[forks-url]: https://github.com/github_username/repo_name/network/members\r\n[stars-shield]: https://img.shields.io/github/stars/github_username/repo_name.svg?style=for-the-badge\r\n[stars-url]: https://github.com/github_username/repo_name/stargazers\r\n[issues-shield]: https://img.shields.io/github/issues/github_username/repo_name.svg?style=for-the-badge\r\n[issues-url]: https://github.com/github_username/repo_name/issues\r\n[license-shield]: https://img.shields.io/github/license/github_username/repo_name.svg?style=for-the-badge\r\n[license-url]: https://github.com/github_username/repo_name/blob/master/LICENSE.txt\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 plroit  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "QA based Semantics",
    "version": "1.1.14",
    "project_urls": {
        "Homepage": "https://github.com/plroit/qasem_parser"
    },
    "split_keywords": [
        "qasem",
        "nlp",
        "semantics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "317d39b98a30b54d173f6c52ccfc36db3e480d6699a4151752156314ba3e42af",
                "md5": "74e9c730b50b2c6374486b50717be5e1",
                "sha256": "a81f9f2341c833fff8363cddb462e6b899e9428d8fa641b68d9c5207061cd64d"
            },
            "downloads": -1,
            "filename": "qasem_parser-1.1.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "74e9c730b50b2c6374486b50717be5e1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 16012,
            "upload_time": "2024-01-31T18:21:40",
            "upload_time_iso_8601": "2024-01-31T18:21:40.772107Z",
            "url": "https://files.pythonhosted.org/packages/31/7d/39b98a30b54d173f6c52ccfc36db3e480d6699a4151752156314ba3e42af/qasem_parser-1.1.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7a82abbf8bc2d47c6442f64c945644911edf48ac3871e44fa3138dbc80459543",
                "md5": "e7ee012f60bf846bcfb4bfa06725e5eb",
                "sha256": "720252889f89ecdd86bb6476b4c60b50b2dda7c9ec5aea622fa6e274d9a74ff8"
            },
            "downloads": -1,
            "filename": "qasem_parser-1.1.14.tar.gz",
            "has_sig": false,
            "md5_digest": "e7ee012f60bf846bcfb4bfa06725e5eb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 15972,
            "upload_time": "2024-01-31T18:21:42",
            "upload_time_iso_8601": "2024-01-31T18:21:42.647269Z",
            "url": "https://files.pythonhosted.org/packages/7a/82/abbf8bc2d47c6442f64c945644911edf48ac3871e44fa3138dbc80459543/qasem_parser-1.1.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-31 18:21:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "plroit",
    "github_project": "qasem_parser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "torch",
            "specs": [
                [
                    "~=",
                    "1.10.2"
                ]
            ]
        },
        {
            "name": "transformers",
            "specs": [
                [
                    "~=",
                    "4.20.1"
                ]
            ]
        }
    ],
    "lcname": "qasem-parser"
}
        
Elapsed time: 0.21019s