Skip to content

propbank-timeout-conditions: Error handling for frame extraction

This merge request proposes to add better error handling to frame extraction through PyFCG. Previously, when calling comprehend on a PropBankAgent the following error would be thrown when a timeout of 60 had exceeded: No applicable methods for #<STANDARD-GENERIC-FUNCTION PROPBANK-GRAMMAR::FRAMES ...> with args (PROPBANK-GRAMMAR::TIME-OUT)

Note: To implement this, changes were made to the PyFCG, FCG-Go and babel repositories. To see the changes in effect, all three repos should be on their propbank-timeout-conditions branch. Each repo has a merge-request titled "propbank-timeout-conditions: Error handling for frame extraction", all sharing this same description.

Testing

Testing can be done by first loading a pretrained ProbBank agent.

import pyfcg as fcg
fcg.init(launch=False)

pb_agent = fcg.PropBankAgent()
pretrained_grammar_image = fcg.load_resource('pb-en.store')
pb_agent.load_grammar_image(pretrained_grammar_image)

The different errors can be encountered by using a very short timeout or disabling your internet connection.

pb_agent.comprehend("I am testing the error handling.", timeout=0.1)
# FcgError: Utterance could not be de-rendered within a time frame of 0.1 seconds.
pb_agent.comprehend("I am testing the error handling.", timeout=0.3)
# FcgError: Utterance could not be comprehended within a time frame of 0.3 seconds.
pb_agent.comprehend("I am testing the error handling.") # without internet connection
# FcgError: Spacy API could not be reached.

Implementation

PyFCG

The comprehend method of a PropBankAgent now has an extra optional argument: timeout=60. This timeout is passed through the comprehend_and_extract_frames route.

FCG-Go

fcg-comprehend-and-extract-frames passes this timeout when calling propbank-grammar::comprehend-and-extract-frames-with-error. Surrounding this call is now a handler-case distinguishing between a timeout due to a lost Spacy-API connection and a timeout due to overly long processing.

Babel

The timeout might be exceeded in propbank-grammar::comprehend-and-extract-frames-with-error

  • during the de-render phase (in which case the Space-API took too long).
  • during comprehend-with-rolesets (in which case the FCG application process took too long).

I defined a timeout-error condition which is thrown in propbank-comprehend-with-error with a fitting error message to discern between these two cases.

Edited by Arno Temmerman

Merge request reports

Loading