Skip to main content

PropBank Database and Embeddings

PyPI Python 3.11 Build Status

An API to access PropBank data and generate embeddings from the paper CALAMR: Component ALignment for Abstract Meaning Representation used by the zensols.calamr repository. This creates a database and generates embeddings from PropBank frameset files and makes it available as n API that attempts to reduce the data complexity of the PropBank using an object oriented Pythonic approach. It will automatically download a [distribution file] that contains:

  • An SQLite relational normalized database,
  • Sentence-BERT embeddings for role sets, roles and functions,
  • A CSV file with the corresponding extracted sentences used for the embeddings,
  • A metadata file containing version information and bindings for the embeddings used by the Zensols framework.

The API binds the relational data from the SQLite database with simple, but performant object mappings in Python while allowing a direct row/cursor based access to the data using the Zensols Dbutil API.

If you use this library or the zensols.calamr API, please cite our paper.

Documentation

See the full documentation. The API reference is also available.

Obtaining

The library can be installed with pip from the pypi repository:

pip3 install zensols.propbankdb

Embeddings and Database

A PropBank database with SentenceBERT embeddings for the paper CALAMR: Component ALignment for Abstract Meaning Representation. This is used by the zensols.propbankdb Python API but can be used on its own as well. The database contains roles, rolesets and other PropBank data along with their examples, descriptions, functions etc. embeddings. See the API repository for more information.

Sentence-BERT embeddings are available for the following PropBank frameset files XML fields:

  • Role set names (name attribute)
  • Role descriptions (descr attribute)
  • Function description (defined in the .dtd file from PropBank frameset files repository)

The models and the SQLite PropBank database are automatically downloaded on the first use of the command-line tool or API. However, they can also be downloaded directly.

Usage

The installed software can be used to look up data from the command line, but was designed to be used as an API for data access and embeddings.

Command Line

The command line details are available with the command line help using:

$ propbankdb --help

For example, to get the see.01 role set in JSON format use:

$ propbankdb roleset -f json see.01

API

Access a role set and its embedding from the database:

from zensols.propbankdb import Roleset, Database, ApplicationFactory
db: Database = ApplicationFactory.get_database()
rs: Roleset = db.roleset_stash['see.01']
# print out the rule set, the number of roles it has, and embedding shape
print(rs, len(rs.roles), rs.embedding.shape)
>>> see.01: view 3 torch.Size([768])
# print the roleset information
rs.write()
>>> id:
>>>     label: see.01
>>>     lemma: see
>>>     index: 1
>>> name: view
>>> aliases:
>>>     part_of_speech: PartOfSpeech.verb
>>>     word: see
>>>     part_of_speech: PartOfSpeech.noun
>>>     word: seeing
>>>     part_of_speech: PartOfSpeech.verb
>>>     word: sight
>>>     part_of_speech: PartOfSpeech.noun
>>>     word: sight
>>> roles:
>>>     description: viewer
>>>     function:
>>>         label: PAG
>>>         description: prototypical agent
>>>         group: default
...

The roleshow.py example shows how to use your own application context as a minimum example providing only data access. The role-with-embedding.py example adds more resource libraries necessary to fetch embeddings.

Training

Use the dist.py script to train new embeddings and recreate the database:

  1. Edit the transformer_sent_fixed_resource section model_id in the configuration file to use different embeddings
  2. Start with a clean environment: ./dist.py clean
  3. Create the distribution: ./dist.py package

Citation

If you use this project in your research please use the following BibTeX entry:

@inproceedings{landesCALAMRComponentALignment2024,
  title = {{{CALAMR}}: {{Component ALignment}} for {{Abstract Meaning Representation}}},
  booktitle = {The 2024 {{Joint International Conference}} on {{Computational Linguistics}}, {{Language Resources}} and {{Evaluation}}},
  author = {Landes, Paul and Di Eugenio, Barbara},
  date = {2024-05-20},
  publisher = {International Committee on Computational Linguistics},
  location = {Turin, Italy},
  eventtitle = {{{LREC-COLING}} 2024}
}

Changelog

An extensive changelog is available here.

Community

Please star this repository and let me know how and where you use this API. Contributions as pull requests, feedback and any input is welcome.

License

MIT License

Copyright (c) 2023 - 2025 Paul Landes

Metadata

Release files for zensols-propbankdb 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for zensols-propbankdb 0.2.1
File Interpreter ABI Platform
zensols_propbankdb-0.2.1-py3-none-any.whl Python 3 none any Details

Release files / zensols_propbankdb-0.2.1-py3-none-any.whl

Download URL zensols_propbankdb-0.2.1-py3-none-any.whl
Size 30.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
915bc57ac12c4d5f8a9e2c786bb457f8c9be6a195158c454758c4b91fe2cb491
BLAKE2b-256 checksum
How to use checksums
3a0208018bce6692efd49e4a0d072e23979eb8362b4289a14a25a4aea5ab6619
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

0.2.1 This release

1 release file

0.2.0

1 release file

0.1.0

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page