Open zlmaker opened 1 year ago
thanks for the issue.
here is the code of qid_to_str
:
from paths import path_queries
import pickle
import pandas as pd
def qid_to_str(qids, dataset):
"""Convert integer qids to str"""
qid_series = pd.Series(qids)
qid_series = qid_series.astype(str)
if dataset=='cast19':
qid_series = qid_series.apply(lambda x: str(x[:2])+'_'+str(x[2:]))
elif dataset=='cast21':
qid_series = qid_series.apply(lambda x: str(x[:3])+'_'+str(x[3:]))
elif dataset=='cast20':
with open(path_queries['cast20']['qid_mapping'], 'rb') as f:
qid_mapping = pickle.load(f)
qid_series = qid_series.apply(lambda x: qid_mapping[x])
return qid_series
note that you need to pass as an argument a mapping for the queries. sorry, I wrote the code very much in a hurry back then, so it's pretty messy.
in "from utils import qid_to_str" , where from "utils"?