Skip to content

Commit

Permalink
Simplify ir-measures evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
mam10eks committed Nov 21, 2023
1 parent 3194921 commit 8a08884
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions ir-measures/ir_measures_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import re
from pathlib import Path
from typing import Tuple, Dict, List, Optional
import gzip

import ir_measures
from ir_measures import Qrel, ScoredDoc, Measure, Metric
Expand Down Expand Up @@ -876,15 +877,9 @@ def render_results(run_file, irds_id, output_path, top_k=10):
excerpt_for_rendering['queries'] = {k: json.loads(irds_loader.map_query_as_jsonl(v)) for k,v in excerpt_for_rendering['queries'].items()}
excerpt_for_rendering['documents'] = {k: json.loads(irds_loader.map_doc(v)) for k,v in excerpt_for_rendering['documents'].items()}

with open(Path(output_path) / '.data-top-10-for-rendering.jsonl', 'w') as output_file:
with gzip.open(Path(output_path) / '.data-top-10-for-rendering.json.gz', 'w') as output_file:
output_file.write(json.dumps(excerpt_for_rendering))

from diffir.run import diff_from_local_data
_, rendered_serp = diff_from_local_data([str(Path(run_file).resolve())], [str((Path(output_path) / '.data-top-10-for-rendering.jsonl').resolve())], cli=False, web=True, print_html=False)

with open(Path(output_path) / 'serp.html', 'w') as output_file:
output_file.write(rendered_serp)


def irds_id_from_metadata_or_none(f):
try:
Expand Down

0 comments on commit 8a08884

Please sign in to comment.