Skip to content

Instantly share code, notes, and snippets.

@brenoferreira
Last active December 19, 2015 20:39
Show Gist options
  • Save brenoferreira/6014526 to your computer and use it in GitHub Desktop.
Save brenoferreira/6014526 to your computer and use it in GitHub Desktop.
def test():
T = []
T.append("it is what it is")
T.append("what is it")
T.append("it is a banana")
ii = inverseIndex(T)
for i in ii:
print(i)
def makeInverseIndex(strlist):
res = {}
for (i, doc) in enumerate(strlist):
for word in doc.split():
if word in doc:
if not word in res:
res[word] = set([i])
else:
res[word].add(i)
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment