propbank module
- class py_amr2fred.propbank.Propbank
Bases:
objectA 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.
- 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:
word (str) – The word to search for in the frame matrix.
frame_field (Glossary.PropbankFrameFields) – The field to search for the word in the frame.
- Returns:
A list of frames that match the given word in the specified field.
- Return type:
- 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:
- 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.
- 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: