| |
- file_read_strings(path)
- Read a file into a list of strings. If the file cannot be
read, print an error message and return an empty list.
- file_write_strings(path, lst)
- Write a list of strings (or things that can be converted to
strings) to a file. If the file cannot be written, print an
error message.
path: A file path
lst: A list of strings or things that can be converted to strings.
- lower_keys(obj)
- Convert keys in a dict (and nested dicts) to lowercase.
- read_qrels(path)
- Read a file in .qrels format. Return it as a list [qid, eid, rel].
- read_queries(path)
- Read a file in .qry format. Return it as a dict of qid:query.
- read_rankings(path, max_rank=None)
- Get a list of rankings for a set of queries. Each ranking is
a list of (score, externalId) tuples.
queries: A dict of {query_id:query_string}.
max_rank: Optional. If provided, ignore all documents beyond max_rank.
- str_to_num(obj)
- Convert strings that look like numbers to int or float. If obj is
a list or a dict, call recursively on the list elements or dict
values. Objects that cannot be converted are returned unchanged.
|