""" Access and manage a feature-based learning-to-rank (Ltr) reranker. """ # Copyright (c) 2024, Carnegie Mellon University. All Rights Reserved. import os import re import subprocess import Util import PyLu from QryParser import QryParser class RerankWithLtr: """ Access and manage a feature-based learning-to-rank (Ltr) reranker. """ # -------------- Methods (alphabetical) ---------------- # def __init__(self, parameters): # Store the parameters for the LTR reranker # Initialization is a good time to create the model that will # be used for reranking. Cleaner code probably does this in a # separate function. # - Get training data from .trainQry and .trainQrels files # - Generate feature vectors for each (qid, docid) tuple # - Possibly normalize vectors # - Write vectors to file # - Call the toolkit to train a model def rerank(self, queries, results): """ Update the results for a set of queries with new scores. queries: A dict of {qid : qString} pairs. results: A dict of {qid : [(score, externalId) ...]} tuples. """ # Generate feature vectors for each (qid, docid) tuple # Possibly normalize vectors # Write vectors to file # Call the toolkit to generate new scores # Use the new scores to update results return(results)