:mod:`capreolus.utils.common` ============================= .. py:module:: capreolus.utils.common Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: capreolus.utils.common.Anserini Functions ~~~~~~~~~ .. autoapisummary:: capreolus.utils.common.download_file capreolus.utils.common.hash_file capreolus.utils.common.padlist capreolus.utils.common.plot_loss capreolus.utils.common.plot_metrics capreolus.utils.common.remove_newline capreolus.utils.common.get_udel_query_expander .. data:: logger .. py:class:: Anserini .. classmethod:: get_fat_jar(cls) .. classmethod:: filter_and_log_anserini_output(cls, line, logger) Ignore DEBUG lines and require other lines pass our logging level .. function:: download_file(url, outfn, expected_hash=None) Download url to the file outfn. If expected_hash is provided, use it to both verify the file was downloaded correctly, and to avoid re-downloading an existing file with a matching hash. .. function:: hash_file(fn) Compute a SHA-256 hash for the file fn and return a hexdigest of the hash .. function:: padlist(list_to_pad, padlen, pad_token=0) Pads a list with pad_token :param list_to_pad: a list of str / int / float, each entry represents the token / token id :param padlen: int, max length of the expected list, list_to_pad would either be truncated or padded to this length :param pad_token: str / int, representing the padding token / token id Returns: padded list .. function:: plot_loss(history, outfn, interactive=False) .. function:: plot_metrics(metrics, outfn, interactive=False, show={'map', 'P_20', 'ndcg_cut_20'}) .. function:: remove_newline(txt) .. function:: get_udel_query_expander()