Learn practical skills, build real-world projects, and advance your career
Updated 5 years ago
This notebook will provide the step by step process for search quality evaluation by computing the avg click rank.
import ujson
from pathlib import Path
import numpy as np
import requests,json
Load the query corpus
def read_jsonl(file_path):
with Path(file_path).open('r', encoding='utf8') as infile:
for line in infile:
try:
yield ujson.loads(line.strip())
except ValueError:
print("Error in reading a jsonline")
continue
def write_jsonl(file_path, lines):
data = [ujson.dumps(line, escape_forward_slashes=False) for line in lines]
Path(file_path).open('w', encoding='utf8').write('\n'.join(data))