Let's say I have a list of lists of strings (stringList):
[['its', 'all', 'ball', 'bearings', 'these', 'days'],
['its', 'all', 'in', 'a', 'days', 'work']]
and I also I have a set of strings (stringSet) that are the unique words from stringList:
{'its', 'all', 'ball', 'bearings', 'these', 'days', 'in', 'a', 'work'}
Using a comprehension, if possible, how can I get a dictionary that maps each word in stringSet to a dictionary of the indexes of stringList that contain that word? In the above example, the return value would be:
{'its': {0,1}, 'all':{0,1}, 'ball':{0}, 'bearings':{0}, 'these':{0}, 'days':{0,1}, 'in':{1}, 'a':{1}, 'work':{1}}
My hangup is how to accumulate the indexes into the dictionary. I'm sure its relatively simple to those further along than I am. Thanks in advance...