Skip to content

Instantly share code, notes, and snippets.

@BURG3R5
Created June 6, 2022 12:27
Show Gist options
  • Save BURG3R5/8ca2bed351696717197debeb8b33d141 to your computer and use it in GitHub Desktop.
Save BURG3R5/8ca2bed351696717197debeb8b33d141 to your computer and use it in GitHub Desktop.
# IN: documents, keywords
inverted_index = {
keyword: tuple(
document_id
for document_id, document_content in documents.items()
if (keyword in document_content)
)
for keyword in keywords
}
# OUT: inverted_index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment