Skip to content

Commit

Permalink
Add a __str__ to the CompositeVocab
Browse files Browse the repository at this point in the history
  • Loading branch information
AngledLuffa committed Nov 21, 2023
1 parent d598368 commit 7662830
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions stanza/models/common/vocab.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ def lens(self):
def items(self, idx):
return self._id2unit[idx]

def __str__(self):
pieces = ["[" + ",".join(x) + "]" for _, x in self._id2unit.items()]
rep = "<{}:\n {}>".format(type(self), "\n ".join(pieces))
return rep

class BaseMultiVocab:
""" A convenient vocab container that can store multiple BaseVocab instances, and support
safe serialization of all instances via state dicts. Each subclass of this base class
Expand Down

0 comments on commit 7662830

Please sign in to comment.