It _is_ a hack; one that I've already used in `CountVectorizer`. I've commented it two lines prior, but maybe putting the following in `utils` is better:
```python
class AutoIncrementer(dict):
    def __missing__(self, key):
        out = len(self)
        self[key] = out
        return out
```
WDYT?