Save week07.py in your exercise folder and run python week07.py --lesson 2. This processor-only exercise reuses the small corpus and encoder from the first lesson. The output shows lexical, dense, fused, and reranked identifiers. It also prints the identifiers eligible for a public caller. No service account or internet connection is needed.
Python’s enumerate(items, 1) attaches positions starting at one. A dictionary stores each identifier’s accumulated fusion score. The membership test checks whether a document survived authorization. This focused example shows rank fusion’s central update:
scores = {}
for ranking in [["A", "B"], ["B", "C"]]:
for rank, identifier in enumerate(ranking, 1):
scores[identifier] = scores.get(identifier, 0) + 1 / (10 + rank)
assert scores["B"] > scores["A"]
The get call returns zero for a missing dictionary entry. B appears twice and receives two contributions; A receives one. In the weekly lab, verify that the restricted record never appears in any public candidate text, including the reranker input. The expected rankings demonstrate transparent fixture behavior, not a benchmark of a trained embedding or reranking model.