-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from ArneBinder/exportable_brat_document_types
make BRAT document types exportable
- Loading branch information
Showing
3 changed files
with
43 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import dataclasses | ||
from typing import Optional | ||
|
||
from pytorch_ie.annotations import BinaryRelation, LabeledMultiSpan, LabeledSpan | ||
from pytorch_ie.core import Annotation, AnnotationList, annotation_field | ||
from pytorch_ie.documents import TextBasedDocument | ||
|
||
|
||
@dataclasses.dataclass(eq=True, frozen=True) | ||
class Attribute(Annotation): | ||
annotation: Annotation | ||
label: str | ||
value: Optional[str] = None | ||
score: Optional[float] = dataclasses.field(default=None, compare=False) | ||
|
||
|
||
@dataclasses.dataclass | ||
class BratDocument(TextBasedDocument): | ||
spans: AnnotationList[LabeledMultiSpan] = annotation_field(target="text") | ||
relations: AnnotationList[BinaryRelation] = annotation_field(target="spans") | ||
span_attributes: AnnotationList[Attribute] = annotation_field(target="spans") | ||
relation_attributes: AnnotationList[Attribute] = annotation_field(target="relations") | ||
|
||
|
||
@dataclasses.dataclass | ||
class BratDocumentWithMergedSpans(TextBasedDocument): | ||
spans: AnnotationList[LabeledSpan] = annotation_field(target="text") | ||
relations: AnnotationList[BinaryRelation] = annotation_field(target="spans") | ||
span_attributes: AnnotationList[Attribute] = annotation_field(target="spans") | ||
relation_attributes: AnnotationList[Attribute] = annotation_field(target="relations") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters