i am trying to make an inversed document index, therefore i need to know from all unique words in a collection in which doc they occur and how often.
i have used this an
In the AutoVivification class, you define
value = self[item] = type(self)()
return value
which returns an instance of self, which is an AutoVivification in that context. The error becomes then clear.
Are you sure you want to return an AutoVivification on any missing key query? From the code, I would assume you want to return a normal dictionary with string key and int values.
By the way, maybe you would be interested in the defaultdict class.