Find reference code relevant to target file from provided cache
(
target_file: str,
index_cache: Dict[str, Dict],
keywords: List[str] = None,
max_results: int = 10,
)
| 173 | |
| 174 | |
| 175 | def find_relevant_references_in_cache( |
| 176 | target_file: str, |
| 177 | index_cache: Dict[str, Dict], |
| 178 | keywords: List[str] = None, |
| 179 | max_results: int = 10, |
| 180 | ) -> List[Tuple[CodeReference, float]]: |
| 181 | """Find reference code relevant to target file from provided cache""" |
| 182 | all_references = [] |
| 183 | |
| 184 | # Collect reference information from all index files |
| 185 | for repo_name, index_data in index_cache.items(): |
| 186 | references = extract_code_references(index_data) |
| 187 | for ref in references: |
| 188 | relevance_score = calculate_relevance_score(target_file, ref, keywords) |
| 189 | if relevance_score > 0.1: # Only keep results with certain relevance |
| 190 | all_references.append((ref, relevance_score)) |
| 191 | |
| 192 | # Sort by relevance score |
| 193 | all_references.sort(key=lambda x: x[1], reverse=True) |
| 194 | |
| 195 | return all_references[:max_results] |
| 196 | |
| 197 | |
| 198 | def find_direct_relationships_in_cache( |
no test coverage detected