ArneBinder / pytorch-ie

PyTorch-IE: State-of-the-art Information Extraction in PyTorch
MIT License
75 stars 7 forks source link

do not try to infer the `document_type` from the function in `(Iterable)Dataset.map()` #337

Closed ArneBinder closed 1 year ago

ArneBinder commented 1 year ago

With this PR, we re-use the original document type when calling (Iterable)Dataset.map() if no result_document_type is provided. This clarifies the semantics because we do not change the document type except that it is explicitly provided. With this we also do not rely on (maybe wrong) return type annotations anymore and we can use generic functions in map that do not change the document type at all (e.g. trimming spans) which is a quite common case.

This is a breaking change for the case that map() is called with a function that has an annotated return type which is different than the original document type of the dataset.