(self, iterable, special_elems=(UNK, BOS, EOS))
| 32 | class Vocab(collections.abc.Set): |
| 33 | |
| 34 | def __init__(self, iterable, special_elems=(UNK, BOS, EOS)): |
| 35 | # type: (Iterable[T]) -> None |
| 36 | elements = list(special_elems) |
| 37 | elements.extend(iterable) |
| 38 | assert len(elements) == len(set(elements)) |
| 39 | |
| 40 | self.id_to_elem = {i: elem for i, elem in enumerate(elements)} |
| 41 | self.elem_to_id = {elem: i for i, elem in enumerate(elements)} |
| 42 | |
| 43 | def __iter__(self): |
| 44 | # type: () -> Iterator[Union[T, IndexedSet.Sentinel]] |
nothing calls this directly
no outgoing calls
no test coverage detected