Skip to content

Commit

Permalink
Fix type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrl committed Apr 10, 2024
1 parent 5396ea7 commit d8eca03
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions haystack/nodes/other/join_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _concatenate_results(self, results: List[List[Document]], document_map: Dict
Return the documents with the higher score.
"""
list_id = list(document_map.keys())
scores_map = {}
scores_map: Dict[str, float] = {}
for idx in list_id:
tmp = []
for result in results:
Expand All @@ -134,11 +134,11 @@ def _concatenate_results(self, results: List[List[Document]], document_map: Dict
scores_map.update({idx: item_best_score.score})
return scores_map

def _calculate_comb_sum(self, results: List[List[Document]]):
def _calculate_comb_sum(self, results: List[List[Document]]) -> Dict[str, float]:
"""
Calculates a combination sum by multiplying each score by its weight.
"""
scores_map = defaultdict(float)
scores_map: Dict[str, float] = defaultdict(float)
weights = self.weights if self.weights else [1 / len(results)] * len(results)

for result, weight in zip(results, weights):
Expand All @@ -154,7 +154,7 @@ def _calculate_rrf(self, results: List[List[Document]]) -> Dict[str, float]:
"""
K = 61

scores_map = defaultdict(float)
scores_map: Dict[str, float] = defaultdict(float)
weights = self.weights if self.weights else [1 / len(results)] * len(results)

# Calculate weighted reciprocal rank fusion score
Expand Down

0 comments on commit d8eca03

Please sign in to comment.