Helper function for merge. Takes a dictionary whose values are lists and returns a dict with the elements of each list as keys and the original keys as values.
(self, data)
| 215 | return self |
| 216 | |
| 217 | def __dict_invert(self, data): |
| 218 | """Helper function for merge. |
| 219 | |
| 220 | Takes a dictionary whose values are lists and returns a dict with |
| 221 | the elements of each list as keys and the original keys as values. |
| 222 | """ |
| 223 | outdict = {} |
| 224 | for k,lst in data.items(): |
| 225 | if isinstance(lst, str): |
| 226 | lst = lst.split() |
| 227 | for entry in lst: |
| 228 | outdict[entry] = k |
| 229 | return outdict |
| 230 | |
| 231 | def dict(self): |
| 232 | return self |