Complete the code to combine semantic and keyword search scores by adding them.
final_score = semantic_score [1] keyword_scoreWe add semantic and keyword scores to get a combined relevance score.
Complete the code to normalize the semantic vector before searching.
normalized_vector = semantic_vector [1] np.linalg.norm(semantic_vector)Dividing by the vector's norm scales it to length 1, which is normalization.
Fix the error in the code to filter documents containing the keyword 'AI'.
filtered_docs = [doc for doc in documents if 'AI' [1] doc['keywords']]
The 'in' keyword checks if 'AI' is inside the keywords list of each document.
Fill both blanks to create a dictionary of document IDs and their combined scores, filtering for scores above 0.5.
result = {doc['id']: doc['semantic_score'] [1] doc['keyword_score'] for doc in docs if (doc['semantic_score'] [2] doc['keyword_score']) > 0.5}We add semantic and keyword scores to get combined scores and filter those above 0.5.
Fill all three blanks to create a list of document titles where the combined score is above 0.7.
top_titles = [doc[[1]] for doc in docs if (doc[[2]] + doc[[3]]) > 0.7]
We select the 'title' field for documents where the sum of 'semantic_score' and 'keyword_score' is greater than 0.7.