Skip to content

Instantly share code, notes, and snippets.

@techykajal
Created August 28, 2021 13:37
Show Gist options
  • Select an option

  • Save techykajal/d89a13ea5b0b2d02a829a946b0461556 to your computer and use it in GitHub Desktop.

Select an option

Save techykajal/d89a13ea5b0b2d02a829a946b0461556 to your computer and use it in GitHub Desktop.
# function to load dictionary and doc to term matrix from the file
def load_dict_and_docterm_matirx(dict_path, matrix_path):
"""
This fucntion will load and return
dictionary and doc term matrix
Arguments:
dict_path: path to corpus dictionary
matrix_path: path to corpus document to term matrix
returns:
dictionary and doc-term matrix
"""
dictionary = corpora.Dictionary.load(dict_path)
doc_term_matrix = corpora.MmCorpus(matrix_path)
return dictionary, doc_term_matrix
dictionary, doc_term_matrix = load_dict_and_docterm_matirx(dict_file_path, matrix_file_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment