implementation inverse index in python