Last active
December 19, 2015 20:39
-
-
Save brenoferreira/6014526 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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