zensols.propbankdb package

Submodules

zensols.propbankdb.app module

zensols.propbankdb.cli module

zensols.propbankdb.dapp module

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=None, *, 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=None, *, 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

zensols.propbankdb.embedpop module

zensols.propbankdb.load module

zensols.propbankdb.pack module

Module contents