def calc_doc_len(doc: Document, tf_idf: TfIdf) -> float: result = 0 for word in doc.words: result = result + math.pow(tf_idf.get(word, {}).get(doc, 0), 2) return math.sqrt(result)