From 3d68d4d6e27522766256cbf17af059a06bc0120b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maik=20Fr=C3=B6be?= Date: Thu, 12 Dec 2024 10:13:09 +0100 Subject: [PATCH] mf --- ir_axioms/axiom/query_aspects.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ir_axioms/axiom/query_aspects.py b/ir_axioms/axiom/query_aspects.py index 949fdd4..1c272a1 100644 --- a/ir_axioms/axiom/query_aspects.py +++ b/ir_axioms/axiom/query_aspects.py @@ -196,15 +196,19 @@ def preference( document1: RankedDocument, document2: RankedDocument ): - query_terms = context.term_set(query) + query_terms = set(context.term_set(query)) s1, s2 = set(), set() - for query_term in query_terms: if context.term_frequency(document1, query_term) > 0: s1.add(query_term) if context.term_frequency(document2, query_term) > 0: s2.add(query_term) + if not all(i in s1 for i in query_terms): + s1 = set() + if not all(i in s2 for i in query_terms): + s2 = set() + return strictly_greater(s1, s2) @@ -233,6 +237,7 @@ def preference( document2_terms = context.term_set(document2) query_term_count1 = query_terms & document1_terms query_term_count2 = query_terms & document2_terms + return strictly_greater(len(query_term_count1), len(query_term_count2))