Skip to content

Commit 6b689a4

Browse files
committed
parent and child type fix + removing payload initialization
1 parent 997e338 commit 6b689a4

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

forte/data/extractors/relation_extractor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ def initialize(self, config: Union[Dict, Config]):
6969
"`entry_class` to this extractor " "must be a Link tpe."
7070
)
7171

72-
self._parent_class: Type[Annotation] = self._entry_class.ParentType
72+
self._parent_class: Type[Annotation] = self._entry_class.ParentType # type: ignore
7373
if not issubclass(self._parent_class, Annotation):
7474
raise ProcessorConfigError(
7575
f"The parent class of the provided {self.config.entry_type}"
7676
" must be an Annotation."
7777
)
7878

79-
self._child_class: Type[Annotation] = self._entry_class.ChildType
79+
self._child_class: Type[Annotation] = self._entry_class.ChildType # type: ignore
8080
if not issubclass(self._child_class, Annotation):
8181
raise ProcessorConfigError(
8282
f"The child class of the provided {self.config.entry_type}"

forte/data/ontology/core.py

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from collections.abc import MutableSequence, MutableMapping
2222
from dataclasses import dataclass
2323
from typing import (
24+
Any,
2425
Iterable,
2526
Optional,
2627
Tuple,
@@ -500,6 +501,11 @@ def data(self, array: Union[np.ndarray, List]):
500501

501502

502503
class BaseLink(Entry, ABC):
504+
505+
# this type Any is needed since subclasses of this class will have new types
506+
ParentType: Any = Entry
507+
ChildType: Any = Entry
508+
503509
def __init__(
504510
self,
505511
pack: ContainerType,

forte/data/ontology/top.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,10 @@ class Annotation(Entry):
9393
end: int
9494
payload_idx: int
9595

96-
def __init__(
97-
self, pack: PackType, begin: int, end: int, text_payload_idx: int = 0
98-
):
96+
def __init__(self, pack: PackType, begin: int, end: int):
9997
self._span: Optional[Span] = None
10098
self.begin: int = begin
10199
self.end: int = end
102-
self.payload_idx: int = text_payload_idx
103100
super().__init__(pack)
104101

105102
def __getstate__(self):
@@ -609,14 +606,11 @@ class AudioAnnotation(Entry):
609606
end: int
610607
payload_idx: int
611608

612-
def __init__(
613-
self, pack: PackType, begin: int, end: int, audio_payload_idx: int = 0
614-
):
609+
def __init__(self, pack: PackType, begin: int, end: int):
615610

616611
self._span: Optional[Span] = None
617612
self.begin: int = begin
618613
self.end: int = end
619-
self.payload_idx: int = audio_payload_idx
620614
super().__init__(pack)
621615

622616
@property

0 commit comments

Comments
 (0)