Warn about nonexistent OMW offsets #2974
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2973: instead of raising a fatal error when an offset is not found in WordNet, only raise a warning, so that batch processing can continue. This is especially handy with OMW, which is known to contain some references to nonexistent offsets (cf. omwn/omw-data#24 (comment)).
With this PR, a list of offfsets is returned, with None instead of eventual incorrect offsets, in addition to any correct offset:
[Synset('apart.r.01'), None]
Meanwhile, a non-fatal warning is wriiten to the standard error stream, with details about the nonexistent synset offset:
Note: maybe it could be worthwile to go through the 12 calls of the WordNetError class in wordnet.py, to see if some other of the raised errors could also be replaced by a non-fatal call of warnings.warn().