Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/document typed #95

Merged
merged 25 commits into from
Mar 5, 2022
Merged

Refactor/document typed #95

merged 25 commits into from
Mar 5, 2022

Conversation

ArneBinder
Copy link
Owner

@ArneBinder ArneBinder commented Mar 4, 2022

This PR cleans up and simplifies the Document (improved version of #93).

It contains the following changes:

  • annotations and predictions as attributes of Document with type AnnotationCollection to reuse its functionality
  • add class AnnotationCollection that holds the attributes labels: TypedAnnotationCollection[Label], spans: TypedAnnotationCollection[LabeledSpan], and binary_relations: TypedAnnotationCollection[BinaryRelation] (for now) and some helper functions to add annotations or enumerate the collections/layers.
  • add class TypedAnnotationCollection[T_annotation] as mapping from layer names to List[T_annotation]s with some helper methods.
  • add construct_document that allows to easily create a Document from a text, spans and binary_relations (both as mapping from names to iterables of the respective annotations). This was previously sitting in tests.helpers.document_utils, but seems to be useful also in other places than tests.
  • fix pipeline test for TransformerRETextClassificationTaskModule: use pytest.approx to compare floats

@ArneBinder ArneBinder requested a review from ChristophAlt March 4, 2022 12:18
@ArneBinder ArneBinder mentioned this pull request Mar 4, 2022
@ChristophAlt
Copy link
Collaborator

I'd prefer this version for the moment. It's less concise but more explicit about what's going on.

@ArneBinder ArneBinder added the refactoring Refactoring label Mar 4, 2022
@ArneBinder ArneBinder force-pushed the refactor/document_typed branch from f2b29d6 to 3e0c861 Compare March 4, 2022 15:39
@ArneBinder
Copy link
Owner Author

@ChristophAlt I just rebased onto main, should be ready to merge.

@ChristophAlt
Copy link
Collaborator

Looks good! Could you also adapt the examples in the README to the change? Then it should be ready to merge.

@ArneBinder
Copy link
Owner Author

ArneBinder commented Mar 4, 2022

@ChristophAlt The readme should be fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants