zensols.propbankdb package

Submodules

zensols.propbankdb.app module

An API to access the frameset database and generate embeddings from them.

class zensols.propbankdb.app.Application(config_factory, db)[source]

Bases: object

Access the Frameset database and generate embeddings from them.

__init__(config_factory, db)
config_factory: ConfigFactory

Used to get the metadata configuration from the install.

db: Database

A data access object for all frame set data.

info()[source]

Print the installed distribution library inforamtion.

Return type:

Configurable

predicate(lemma, format=Format.text)[source]

Dump a role set.

Parameters:
  • id – the lemma of the predicate (i.e. see)

  • format (Format) – the format of the output

roleset(id, format=Format.text)[source]

Dump a role set.

Parameters:
  • id (str) – the role set ID (i.e. see.01)

  • format (Format) – the format of the output

search_roleset(pattern)[source]

Find role set IDs.

Parameters:

pattern (str) – the regular expression to match role set IDs

class zensols.propbankdb.app.Format(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

The format of show type CLI actions.

json = 2
text = 1

zensols.propbankdb.cli module

Command line entry point to the application.

class zensols.propbankdb.cli.ApplicationFactory(*args, **kwargs)[source]

Bases: ApplicationFactory

__init__(*args, **kwargs)[source]
classmethod get_database()[source]

Get the frameset database.

Return type:

Database

zensols.propbankdb.cli.main(args=['/Users/landes/opt/lib/pixi/envs/zensols_relpo/bin/sphinx-build', '-M', 'html', '/Users/landes/view/nlp/propbankdb/target/doc/stage', '/Users/landes/view/nlp/propbankdb/target/doc/build'], **kwargs)[source]
Return type:

ActionResult

zensols.propbankdb.dapp module

A separate CLI entry point for creating the distribution file. The distribution file contains the SQLite database file with the frameset structured data and the embeddings for various facets of the contained role sets.

class zensols.propbankdb.dapp.LoadApplication(loader, embedding_generator, packager, cleaner)[source]

Bases: object

Create the deployment distribution file.

__init__(loader, embedding_generator, packager, cleaner)
cleaner: Cleaner

Clean (removes) files the staging files.

embedding_generator: EmbeddingGenerator

Creates sentence embeddings for PropBank objects.

loader: DatabaseLoader

Loads the parsed frameset XML files in to an SQLite database.

package(frameset_limit=None)[source]

(Re)create the deployment artifacts and distribution file.

Parameters:

frameset_limit (int) – the max number of framesets to load

packager: Packager

Packages the staged files in to the deployment file.

zensols.propbankdb.db module

Loads parsed XML files to an SQLite database.

class zensols.propbankdb.db.AliasPersister(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)[source]

Bases: BankObjectPersister

__init__(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)
class zensols.propbankdb.db.BankObjectPersister(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)[source]

Bases: BeanDbPersister

Utility methods to de-hydrate frame set objects from the datbase.

__init__(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)
add_populator(pop)[source]
get_by_id(uid)[source]

Return an object using it’s unique ID, which is could be the row ID in SQLite.

Return type:

BankObject

iterobj()[source]

Iterate through the object instances from the database.

Return type:

Iterable[BankObject]

populators: List[BankObjectPopulator]

The list of other populators to invoke on _populate().

class zensols.propbankdb.db.Database(conn_manager, frameset_persister, predicate_persister, roleset_persister, alias_persister, example_persister, role_persister, role_link_persister, function_persister, relation_persister, roleset_stash, predicate_stash, relation_stash)[source]

Bases: object

A data access object for all frame set data. This provides access to the loader, which parses the XML and loads it in to the database. It also provides methods to re-hydrate object instances from the database.

Important implementation note: Stash references need to be obtained from this instance rather than directly from the ConfigFactory, otherwise it will not be correctly initialized.

__init__(conn_manager, frameset_persister, predicate_persister, roleset_persister, alias_persister, example_persister, role_persister, role_link_persister, function_persister, relation_persister, roleset_stash, predicate_stash, relation_stash)
alias_persister: AliasPersister

`.Alias.

Type:

Persists instances of

Type:

class

conn_manager: ConnectionManager

The relational database (SQLite only for now) connection manager.

See:

installer

example_persister: ExamplePersister

`.Example.

Type:

Persists instances of

Type:

class

frameset_persister: FramesetPersister

`.Frameset.

Type:

Persists instances of

Type:

class

function_persister: FunctionPersister

`.Function.

Type:

Persists instances of

Type:

class

get_frameset(file_name)[source]

Return the Frameset that was parsed by file_name.

Return type:

Frameset

get_framesets()[source]

Return an iterable of Framesets.

Return type:

Iterable[Frameset]

get_predicate(lemma)[source]

Return the predicate for ``lemma`.

Return type:

Predicate

get_predicates()[source]

Return an iterable of predicates.

Return type:

Iterable[Predicate]

predicate_persister: PredicatePersister

`.Predicate.

Type:

Persists instances of

Type:

class

predicate_stash: Stash

A stash adapatation of predicate_persister.

relation_persister: RelationPersister

`.Relation.

Type:

Persists instances of

Type:

class

relation_stash: Stash

A stash adapatation of relation_persister.

`.RoleLink.

Type:

Persists instances of

Type:

class

role_persister: RolePersister

`.Role

Type:

Persists instances of

Type:

class

roleset_persister: RolesetPersister

`.Roleset.

Type:

Persists instances of

Type:

class

roleset_stash: Stash

A stash adapatation of roleset_persister.

class zensols.propbankdb.db.ExamplePersister(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)[source]

Bases: BankObjectPersister

__init__(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)
class zensols.propbankdb.db.FramesetPersister(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)[source]

Bases: BankObjectPersister

__init__(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)
get_by_file_name(file_name)[source]
Return type:

Frameset

class zensols.propbankdb.db.FunctionPersister(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None)[source]

Bases: BeanDbPersister

Utility persister to access :class:`.Function`s by label and ID. This is a somewhat like a GoF flyweight pattern in that it attempts to minimize the memory footprint.

__init__(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None)
get()[source]

Return using the SQL provided by the entry identified by select_name.

Return type:

Tuple[Function]

get_by_id(uid)[source]

Return an object using it’s unique ID, which is could be the row ID in SQLite.

Return type:

Function

get_by_label(label)[source]
Return type:

Function

class zensols.propbankdb.db.InstallerConnectionManager(db_file, create_db=True, installer=None)[source]

Bases: SqliteConnectionManager

A connection manager that first downloads the distribution SQLite Propbankdb file.

__init__(db_file, create_db=True, installer=None)
installer: Optional[Installer] = None

The distribution file resource downloader. If this is set, it is downloaded, uncompressed and conn_manager`s ``db_file` parent path set to the resource.

class zensols.propbankdb.db.PredicatePersister(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)[source]

Bases: BankObjectPersister

__init__(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)
get_by_lemma(lemma)[source]
Return type:

Predicate

class zensols.propbankdb.db.RelationPersister(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)[source]

Bases: BankObjectPersister

Utility persister to access :class:`.Relation`s by label and ID. This is a somewhat like a GoF flyweight pattern in that it attempts to minimize the memory footprint.

__init__(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)
get()[source]

Return using the SQL provided by the entry identified by select_name.

Return type:

Tuple[Function]

get_by_id(uid)[source]

Return an object using it’s unique ID, which is could be the row ID in SQLite.

Return type:

Function

get_by_label(label)[source]
Return type:

Function

class zensols.propbankdb.db.RoleLinkPersister(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)[source]

Bases: BankObjectPersister

__init__(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)
class zensols.propbankdb.db.RolePersister(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)[source]

Bases: BankObjectPersister

__init__(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)
class zensols.propbankdb.db.RolesetPersister(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)[source]

Bases: BankObjectPersister

__init__(conn_manager, sql_file=None, row_factory='tuple', select_name=None, select_by_id_name=None, select_exists_name=None, insert_name=None, update_name=None, delete_name=None, keys_name=None, count_name=None, _db=None, populators=<factory>)
get_by_role_id(role_id)[source]
Return type:

Roleset

zensols.propbankdb.domain module

Bank domain classes.

class zensols.propbankdb.domain.Alias(uid=None, part_of_speech=None, word=None)[source]

Bases: BankObject

Surface forms of the Roleset.lemma and their part of speech.

__init__(uid=None, part_of_speech=None, word=None)
part_of_speech: PartOfSpeech = None

The part of speech of word.

uid: int = None

A unique identifier of the function.

word: str = None

“Surface forms of the Roleset.lemma().

exception zensols.propbankdb.domain.BankError[source]

Bases: ApplicationError

Raised for this package’s application errors meant for the command line. It will result in a command line error and usage message.

__module__ = 'zensols.propbankdb.domain'
class zensols.propbankdb.domain.BankObject[source]

Bases: PersistableContainer, Dictable

A base class for all *bank domain classes.

__init__()
property embedding: Tensor | None

The embedding of this instance if embedding population is on.

class zensols.propbankdb.domain.BankObjectPopulator[source]

Bases: ABC

__init__()
abstract populate(bank_object)[source]

Populate bank_object after it was just de-hydrated from the database.

exception zensols.propbankdb.domain.BankParseError[source]

Bases: APIError

Raised for this package’s programmatic errors.

__annotations__ = {}
__module__ = 'zensols.propbankdb.domain'
class zensols.propbankdb.domain.Example(uid=None, name=None, source=None, text=None, propbank=None)[source]

Bases: BankObject

Examples of the usage of the Roleset.

__init__(uid=None, name=None, source=None, text=None, propbank=None)
name: str = None

The name, such as (see-v: ARG0 and ARG1).

propbank: Optional[PropBank] = None

The PropBank annotations for the example, which include token spans of the use of arguments.

source: str = None

The source of the example, such as (ontonotes mz/sinorama/10/ectb_1057).

text: str = None

The text of the example, such as (But recently many people...).

uid: int = None

The database unique identifier.

class zensols.propbankdb.domain.Frameset(uid=None, path=None, predicates=None)[source]

Bases: BankObject

Contains all the Predicate definitions from an file.

__init__(uid=None, path=None, predicates=None)
path: Path = None

The file from which the definition was parsed.

predicates: Tuple[Predicate] = None

The the role sets for a lemmatized word.

uid: int = None

The database unique identifier.

class zensols.propbankdb.domain.Function(uid=None, label=None, description='none', group='unknown')[source]

Bases: BankObject

The role function of the role, such as PAG for prototypical agent. These are taken from the frameset DTD from the AMR 3.0 corpus.

NO_DESCRIPTION: ClassVar[str] = 'none'

A constant used when the function has no description.

__init__(uid=None, label=None, description='none', group='unknown')
description: str = 'none'

The human readable description of the function.

group: str = 'unknown'

The group the function belongs to (i.e. spacial).

property has_description: bool

Whether the function has a description.

label: str = None

The label (i.e. PAG).

uid: int = None

A unique identifier of the function.

class zensols.propbankdb.domain.PartOfSpeech(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

The part of speech identifier in aliases.

adjective = 'j'
adverb = 'r'
noun = 'n'
preposition = 'p'
unknown = '-'
verb = 'v'
class zensols.propbankdb.domain.Predicate(uid=None, lemma=None, rolesets=None)[source]

Bases: BankObject

Contains the role sets for a lemmatized word.

__init__(uid=None, lemma=None, rolesets=None)
lemma: str = None

The lemmetized version of the word this role set describes, such as see.

rolesets: Tuple[Roleset] = None

The associated role sets for this predicate.

uid: int = None

The database unique identifier.

class zensols.propbankdb.domain.PropBank(relative_indicies, relative_tokens, argument_spans)[source]

Bases: BankObject

The PropBank annotations for the Example, which include token spans of the use of arguments.

UNKONWN_INDEX: ClassVar[int] = -1
__init__(relative_indicies, relative_tokens, argument_spans)
argument_spans: Tuple[PropBankArgumentSpan]

The spans of the arguments used in the example.

relative_indicies: Tuple[int]

The 0-index index of the relative token in the example.

relative_tokens: Tuple[str]

The relative token in example (for example, see).

class zensols.propbankdb.domain.PropBankArgumentSpan(type, span, token)[source]

Bases: BankObject

An argument span used in a PropBank.

__init__(type, span, token)
span: Tuple[int, int]

The 0-index inclusive token span in form (start, end).

token: str

The token string selected by span.

type: str

The type (index) of argument (for example, ARG0).

class zensols.propbankdb.domain.Reification(concept, source_argument, target_argument)[source]

Bases: BankObject

Reifications are a particular kind of transformation that replaces an edge relation with a new node and two outgoing edge relations, with one inverted.

__init__(concept, source_argument, target_argument)
concept: RolesetId

The concept to add.

source_argument: int

The source argument used to index.

target_argument: int

The target argument to create.

class zensols.propbankdb.domain.Relation(uid=None, label=None, type=None, description=None, regex=None, reification=None)[source]

Bases: BankObject

Represents an AMR relation, which is a label on the edge an an AMR graph such as :ARG0-of. Note that a relation is often referred to as a role in the context of Penman notation. However, you can think of an instance of role as an edge in am AMR graph as an instance of this class.

REGEX: ClassVar[re.Pattern] = re.compile('^:([^0-9-]+)(\\d+)?(?:-(of))?$')

The regular expresssion used to parse AMR roles.

__init__(uid=None, label=None, type=None, description=None, regex=None, reification=None)
description: str = None

A somewhat human readable string describing the relation. This is used to create the relation embeddings.

label: str = None

The surface name of the relation (i.e. ARG from :ARG0-of).

match(role_str)[source]

Return the regular match for this relaion on an AMR role instance string.

Return type:

Optional[Match]

regex: re.Pattern = None

A regular expression used to match role instances.

reification: Optional[Reification] = None

The reification of the relation if any exist.

type: str = None

The type of relation (i.e. general for :ARG or date for time).

uid: int = None

The database unique identifier.

class zensols.propbankdb.domain.Role(uid=None, description=None, function=None, index=None, role_links=None)[source]

Bases: BankObject

Defines an argument of the propbank role, which in AMR, has the syntax :ARG1 for the second (0-index) second argument.

__init__(uid=None, description=None, function=None, index=None, role_links=None)
description: str = None

The human readable description of the role, such as (Cause of hardening).

function: Function = None

The function of the role, such as PAG for prototypical agent.

index: str = None

The index of the role’s argument, which is a a number, or an M for common adjuncts that don’t qualify for number argument status.

Links to the source banks for this role.

uid: int = None

The database unique identifier.

Bases: BankObject

Contains links in to other source banks.

__init__(uid=None, cls=None, resource=None, version=None, name=None)
cls: str = None

The roleset’s levine class, which is the ID in to the bank such as other_cos-45.4.

name: str = None

The name of the role, such as agent or cause.

resource: RoleResource = None

The name of the source bank, such as VerbNet.

uid: int = None

The database unique identifier.

version: str = None

The version of the source bank, such as verbnet3.3.

write(depth=0, writer=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]

Write this instance as either a Writable or as a Dictable. If class attribute _DICTABLE_WRITABLE_DESCENDANTS is set as True, then use the write() method on children instead of writing the generated dictionary. Otherwise, write this instance by first creating a dict recursively using asdict(), then formatting the output.

If the attribute _DICTABLE_WRITE_EXCLUDES is set, those attributes are removed from what is written in the write() method.

Note that this attribute will need to be set in all descendants in the instance hierarchy since writing the object instance graph is done recursively.

Parameters:
  • depth (int) – the starting indentation depth

  • writer (TextIOBase) – the writer to dump the content of this writable

class zensols.propbankdb.domain.RoleResource(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

The source bank of the role. This has the XML attribute resource.

framenet = 2
verbnet = 1
class zensols.propbankdb.domain.Roleset(uid=None, id=None, name=None, aliases=None, roles=None, examples=None)[source]

Bases: BankObject

A bank role set entry that contains a grouping of :class:`.Role`s.

__init__(uid=None, id=None, name=None, aliases=None, roles=None, examples=None)
aliases: Tuple[Alias] = None

The surfrace forms of the role set.

examples: Tuple[Example] = None

The examples for the roleset.

id: RolesetId = None

The *bank identifier of the role set, wuch as see.01.

name: str = None

The human readable short description of the role set, such as view.

roles: Tuple[Role] = None

The roles that define this set.

uid: int = None

The database unique identifier.

class zensols.propbankdb.domain.RolesetId(label=None, lemma=None, index=None, normalize=True)[source]

Bases: BankObject

A role set identifier identifier such as see.01 or see-01. Note the later example is to support AMR formatted nodes.

See:

Roleset

See:

Banarescu et al (2003)

__init__(label=None, lemma=None, index=None, normalize=True)
index: Optional[int] = None

The numeric index part of the identifier (i.e. 1 from label see-01).

property is_valid: bool

Whether this is a valid formatted role set ID, which means it has both a lemma and index.

label: str = None

The surface label of the ID (i.e. see-01).

lemma: Optional[str] = None

The lemma part of the identifier (i.e. see from label see-01).

normalize: InitVar[bool] = True

Whether to normalize the label.

zensols.propbankdb.embedgen module

Creates embeddings for PropBank objects. This module is used to create the distribution file’s embeddings with EmbeddingGenerator. The distribution file’s contents include the Framenet object graphs, embeddings and a metadata files used to configure EmbeddingPopulator.embed_model, which is used by the package to populate the embeddings.

class zensols.propbankdb.embedgen.EmbeddingGenerator(config, doc_parser, word_piece_doc_factory, populator, db, output_dir, output_decimals, output_limit=9223372036854775807)[source]

Bases: object

Creates sentence embeddings for PropBank objects (see module docs).

__init__(config, doc_parser, word_piece_doc_factory, populator, db, output_dir, output_decimals, output_limit=9223372036854775807)
config: Configurable

Used to copy application context in to the metadata file included in the distribution file.

db: Database

Used to get the objects for which to create embeddings.

doc_parser: FeatureDocumentParser

The used for parsing the English in the Framenets.

dump()[source]

Write the embeddings in text format to disk.

output_decimals: int

The number of decimals of each component in the output embedding.

output_dir: Path

The directory where the embedding file is written.

output_limit: int = 9223372036854775807

The maximum number of vocab vectors to write.

populator: EmbeddingPopulator

The embedding populator used to create the embedding keys.

property vector_dimension: int

Get the output dimension embedding size.

word_piece_doc_factory: WordPieceFeatureDocumentFactory

Used to create the embeddings from the language in the Framenets.

write_vectors(emb_writer, sent_writer)[source]

Write the vectors to a text sink.

Return type:

int

zensols.propbankdb.embedpop module

Populate embeddings generated from EmbeddingGenerator.

see:

embedgen

class zensols.propbankdb.embedpop.EmbeddingBankObjectPopulator(embed_populator)[source]

Bases: BankObjectPopulator

__init__(embed_populator)
embed_populator: EmbeddingPopulator
populate(bank_object)[source]

Populate bank_object after it was just de-hydrated from the database.

class zensols.propbankdb.embedpop.EmbeddingPopulator(config, embed_model, function_persister, torch_config, roleset_key_pattern='s~{rs.id.label}', role_key_pattern='r~{rs.id}~{r.index}', function_key_pattern='f-{f.label}', relation_key_pattern='e-{r.label}')[source]

Bases: object

Adds embeddings to certains BankObject instances (see module docs).

DEFAULT_SECTION: ClassVar[str] = 'propbankdb_default'

The default application context section that has the distribution file version.

EMBEDDING_SECTION: ClassVar[str] = 'embedding'

The embedding information section in the distribution metadata config file.

FILE_NAME_OPTION: ClassVar[str] = 'file_name'

The option key in the distribution metadata config file.

META_FILE: ClassVar[str] = 'meta.conf'

The name of the metadata file in the distribution file.

SENT_TEXT_FILE: ClassVar[str] = 'sentence.csv'

The name of the CSV file that has the sentence output with keys.

VERSION_OP: ClassVar[str] = 'version'

The model version configuration option and metadata section.

__init__(config, embed_model, function_persister, torch_config, roleset_key_pattern='s~{rs.id.label}', role_key_pattern='r~{rs.id}~{r.index}', function_key_pattern='f-{f.label}', relation_key_pattern='e-{r.label}')
config: Configurable

Used to check API with model version.

embed_model: WordEmbedModel

The embedding model that was created from EmbeddingGenerator and used to populate data in BankObject instances.

function_key_pattern: str = 'f-{f.label}'

The pattern used format/parse Function keys.

function_persister: FunctionPersister

The persister used to populate embeddings for :class:`.Function`s.

function_to_key(func)[source]

Format Function keys.

Return type:

str

get_metadata_config(add_api=False)[source]

Get the distribution metadata.

Return type:

Configurable

get_sentence(*objs)[source]

Get the sentence used to produce the embedding in objs bank objects.

See:

object_to_key()

Return type:

str

property is_valid_model_version: bool

Return whether the API and model versions are in sync.

object_to_key(*objs)[source]

Generate a key from objs by calling one of the *_to_key methods.

Return type:

str

populate_relation(rel)[source]
populate_roleset(roleset)[source]

Populate embeddings for all of a role set’s object graph.

Parameters:

roleset (Roleset) – the role set with respective BaseObject.embedding fields to be populated

relation_key_pattern: str = 'e-{r.label}'

The pattern used format/parse Relation keys.

relation_to_key(rel)[source]

Format Relation keys.

Return type:

str

role_key_pattern: str = 'r~{rs.id}~{r.index}'

The pattern used format/parse Role keys.

role_to_key(roleset, role)[source]

Format Role keys.

Return type:

str

roleset_key_pattern: str = 's~{rs.id.label}'

The pattern used format/parse Roleset keys.

roleset_to_key(roleset)[source]

Format Roleset keys.

Return type:

str

torch_config: TorchConfig

Used to copy the embedding matrix to the GPU.

zensols.propbankdb.load module

Parses frameset XML files from the file system.

class zensols.propbankdb.load.DatabaseLoader(parser, relation_loader, db, frameset_limit=9223372036854775807)[source]

Bases: object

Loads the parsed frameset XML files in to an SQLite database.

__init__(parser, relation_loader, db, frameset_limit=9223372036854775807)
clear()[source]

Drop the database, which deletes the SQLite file.

db: Database

A data access object to the frameset database.

frameset_limit: int = 9223372036854775807

The max number of framesets to load.

parser: FramesetParser

Parses all frameset XML files on the file system, which is then used to load the database.

relation_loader: RelationLoader

Loads AMR role relations.

class zensols.propbankdb.load.FramesetParser(installer, function_path, frames_dir)[source]

Bases: object

Parses all frameset XML files on the file system.

__init__(installer, function_path, frames_dir)
frames_dir: Path

The relative path from where the GitHub propbank files are downloaded and uncompressed.

property function_df: Dict[str, Function]

Keys are function labels/names, values are the function instances.

function_path: Path

A CSV file that has all role functions and their descriptions.

installer: Installer

An installer that points to the GitHub repo where the probank framesets are kept. This points to the source zip file on GitHub.

property xml_dir: Path

The directory that has the frameset XML files.

class zensols.propbankdb.load.RelationLoader(description_mods)[source]

Bases: object

Loads relations from the penman package.

__init__(description_mods)
description_mods: Tuple[Tuple[Pattern, str]]

A tuple of regular expressions and replacement strings for relation descriptions.

zensols.propbankdb.pack module

Package resources for distribution.

class zensols.propbankdb.pack.Packager(stage_dir, archive_dir)[source]

Bases: object

Packages the staged files in to the deployment file.

__init__(stage_dir, archive_dir)
archive_dir: Path

The directory where the deployment file is created.

pack()[source]
stage_dir: Path

The directory to where the staged files to be zipped live.

Module contents