propbank module

class py_amr2fred.propbank.Propbank

Bases: object

A class to represent Propbank data, which includes role and frame matrices.

This class provides methods to read Propbank data from TSV files, search for frames and roles, and find specific relationships between words.

static file_read(file_name: str, delimiter: str = '\t', encoding: str = 'utf8') list

Reads a TSV file and returns its header and rows.

The file is read using the specified delimiter and encoding, and the first row is treated as the header. The function returns a list with the header and the remaining rows.

Parameters:
  • file_name (str) – Path to the file to read.

  • delimiter (str) – The delimiter used to separate columns in the file.

  • encoding (str) – The encoding to use when reading the file.

Returns:

A list containing the header and rows of the file.

Return type:

list

frame_find(word: str, frame_field: PropbankFrameFields) list

Finds frames that match a given word in a specified frame field.

The method searches through the frame matrix and returns a list of frames where the specified field contains the word.

Parameters:
Returns:

A list of frames that match the given word in the specified field.

Return type:

list

static get_propbank()

Returns the singleton instance of the Propbank class.

If the instance does not exist, it will create a new one.

Return type:

Propbank

list_find(word: str, args: list[py_amr2fred.node.Node]) list | None

Finds roles and relationships for a word based on a list of Node objects.

The method iterates over a list of Node objects and searches for roles that match the word using the role_find method. It returns a list of results if enough matches are found.

Parameters:
  • word (str) – The word to search for in the role matrix.

  • args (list[Node]) – A list of Node objects to find roles for.

Returns:

A list of roles if enough matches are found, or None.

Return type:

list | None

role_find(word: str, role_field: PropbankRoleFields, value: str, role_field_2: PropbankRoleFields) list

Finds roles matching a given word and values in specific fields.

This method searches through the role matrix and returns a list of roles that match the provided word, value, and fields.

Parameters:
  • word (str) – The word to search for in the role matrix.

  • role_field (Glossary.PropbankRoleFields) – The field in the role matrix to match the word.

  • value (str) – The value to match in the second role field.

  • role_field_2 (Glossary.PropbankRoleFields) – The second role field to compare the value.

Returns:

A list of roles that match the given word and values.

Return type:

list