All problems
Reranker Feature Build
Problem
Build a four-element reranker feature vector: [retrieval_score, query-overlap count, query length, passage length].
The overlap count is the number of distinct query terms that occur anywhere in the passage.
Hint
Deduplicate the query tokens before counting overlap, but keep the raw lengths.
Test cases
case 1
in: [0.8,["cat","sat"],["the","cat","sat","down"]]
expected: [0.8,2,2,4]
case 2
in: [0.5,["dog"],["cat","dog"]]
expected: [0.5,1,1,2]
case 3
in: [0,[],["a"]]
expected: [0,0,0,1]
case 4
in: [1,["a","a"],["a"]]
expected: [1,1,2,1]
Starter codePython
def reranker_feature_build(retrieval_score, query_tokens, passage_tokens):
# Your code here
pass4 test cases · run your code against them in the editor