Skip to content
Merged
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
10 changes: 5 additions & 5 deletions nlptest/utils/custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __eq__(self, other):

def __str__(self) -> str:
""""""
return self.entity
return f"{self.span.word}: {self.entity}"

def __repr__(self) -> str:
""""""
Expand Down Expand Up @@ -123,14 +123,14 @@ def __getitem__(self, item: Union[Span, int]) -> Optional[NERPrediction]:
return prediction
return None

def to_str_list(self) -> List[str]:
def to_str_list(self) -> str:
"""
Converts predictions into a list of strings.

Returns:
List[str]: predictions in form of a list of strings.
"""
return [x.entity for x in self.predictions]
return ", ".join([str(x) for x in self.predictions if str(x)[-3:] != ': O'])

def __repr__(self) -> str:
""""""
Expand Down Expand Up @@ -163,13 +163,13 @@ class SequenceClassificationOutput(BaseModel):
"""
predictions: List[SequenceLabel]

def to_str_list(self) -> List[str]:
def to_str_list(self) -> str:
"""Convert the output into list of strings.

Returns:
List[str]: predictions in form of a list of strings.
"""
return [x.label for x in self.predictions]
return ",".join([x.label for x in self.predictions])

def __str__(self):
""""""
Expand Down