TF-IDF scoring
Your task
Compute TF-IDF for a tiny corpus. Given docs, a list of documents where each document is a list of word tokens, and a query word, return for each document its TF-IDF weight for that word, in document order. Term frequency tf(word, doc) = count of word in doc / total tokens in doc (0 if the doc is empty). Inverse document frequency idf(word) = ln(N / (1 + df)) + 1, where N is the number of documents and df is the number of documents that contain the word (the +1 is smoothing in the denominator). TF-IDF = tf * idf. Return the list of weights, each rounded to 6 decimals. There are at least 1 document; documents may be empty.
Examples
tfidf_column(docs: list[list[str]], query: str) -> list[float]Example 1
Input
tfidf_column([["the", "cat", "sat"], ["the", "dog", "ran"], ["a", "cat", "cat"]], "cat")Output
[0.333333, 0, 0.666667]