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

add prepare_documents #102

Merged
merged 5 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/pytorch_ie/taskmodules/taskmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ def encode(

@abstractmethod
def encode_input(
self, documents: List[Document]
self,
documents: List[Document],
is_training: bool = False,
) -> Tuple[List[InputEncoding], List[Metadata], Optional[List[Document]]]:
raise NotImplementedError()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ def _encode_text(
return encoding

def encode_input(
self, documents: List[Document]
self,
documents: List[Document],
is_training: bool = False,
) -> Tuple[
List[TransformerReTextClassificationInputEncoding],
List[Metadata],
Expand Down
4 changes: 3 additions & 1 deletion src/pytorch_ie/taskmodules/transformer_seq2seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ def encode_input_strings(self, inputs: List[str]) -> List[TransformerSeq2SeqInpu
]

def encode_input(
self, documents: List[Document]
self,
documents: List[Document],
is_training: bool = False,
) -> Tuple[List[TransformerSeq2SeqInputEncoding], List[Metadata], Optional[List[Document]]]:
input_strings = [self.document_to_input_string(document) for document in documents]
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def prepare(self, documents: List[Document]) -> None:
self.id_to_label = {v: k for k, v in self.label_to_id.items()}

def encode_input(
self, documents: List[Document]
self,
documents: List[Document],
is_training: bool = False,
) -> Tuple[
List[TransformerSpanClassificationInputEncoding],
List[Metadata],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def prepare(self, documents: List[Document]) -> None:
self.id_to_label = {v: k for k, v in self.label_to_id.items()}

def encode_input(
self, documents: List[Document]
self,
documents: List[Document],
is_training: bool = False,
) -> Tuple[
List[TransformerTextClassificationInputEncoding],
List[Metadata],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ def encode_text(
)

def encode_input(
self, documents: List[Document]
self,
documents: List[Document],
is_training: bool = False,
) -> Tuple[
List[TransformerTokenClassificationInputEncoding],
List[Metadata],
Expand Down