file_operations
Miscellaneous file operations used by various parts of the CLTK.
CLTK_DATA_DIR_PRIVATE
module-attribute
make_cltk_path
Take arbitrary number of str arguments (not list) and return expanded, absolute path to a user's (or user-defined) cltk_data dir.
Example: In [8]: make_cltk_path('greek', 'model', 'greek_models_cltk') Out[8]: '/Users/kyle/cltk_data/greek/model/greek_models_cltk'
:type fp_list: str positional arguments :param: : fp_list tokens to join together beginning from cltk_root folder :rtype: str
Source code in cltk/utils/file_operations.py
open_pickle
Open a pickle and return loaded pickle object.
:type path: str :param : path: File path to pickle file to be opened.
Source code in cltk/utils/file_operations.py
md5
Produce an md5 hash of the contents given a filename.
Examples:
import os
import tempfile
temp = tempfile.NamedTemporaryFile(delete=False)
temp.write(b"Hello Wirld!")
temp.close()
md5(temp.name)
# '997c62b6afe9712cad3baffb49cb8c8a'
os.unlink(temp.name)