Skip to content

Instantly share code, notes, and snippets.

@InsiderPhD
Created March 26, 2018 10:54
Show Gist options
  • Save InsiderPhD/6361856a515beb157635e2c6a01975ab to your computer and use it in GitHub Desktop.
Save InsiderPhD/6361856a515beb157635e2c6a01975ab to your computer and use it in GitHub Desktop.
Works with the InvertedIndex.py
# OR query
searchQuery = "about company"
searchTokens = tokeniser.tokenize(searchQuery)
searchNormalised = list()
for t in searchTokens:
searchNormalised.append(porter.stem(t))
postingsList = list()
for t in invertedIndex:
for search in searchNormalised:
if t[0] == search:
for posting in t[1]:
appearsInPostings = None
for p in postingsList:
if(p == posting): appearsInPostings = True
if(appearsInPostings != True):
postingsList.append(posting)
print(postingsList)
for posting in postingsList:
print(documents[posting-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment