Skip to content

Commit

Permalink
Better str representation (#27)
Browse files Browse the repository at this point in the history
* Prevent very long outputs when transcription evaluators are printed

* Change str to repr
  • Loading branch information
yngvem authored Jan 8, 2025
1 parent 48ce012 commit 9d9d1bc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion python/stringalign/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,11 @@ def from_strings(
tokenizer=tokenizer,
)

def __str__(self) -> str:
def __repr__(self) -> str:
return f"LineError('{self.reference}', '{self.predicted}', metadata={self.metadata})"

__str__ = __repr__


@dataclass(frozen=True, slots=True)
class TranscriptionEvaluator:
Expand Down Expand Up @@ -278,3 +280,11 @@ def from_strings(
predictions=predictions,
line_errors=line_errors,
)

def __len__(self) -> int:
return len(self.line_errors)

def __repr__(self) -> str:
return f"TranscriptionEvaluator(len={len(self)})"

__str__ = __repr__

0 comments on commit 9d9d1bc

Please sign in to comment.