@@ -2272,33 +2272,37 @@ def filter_matches_missing_required_phrases(
2272
2272
is_valid = False
2273
2273
break
2274
2274
2275
- has_same_stopwords_pos = True
2276
- for qpos , ipos in zip (qspan , ispan ):
2277
- if qpos not in qkey_span or qpos == qkey_span_end :
2278
- continue
2279
-
2280
- if istopwords_by_pos_get (ipos ) != qstopwords_by_pos_get (qpos ):
2281
- has_same_stopwords_pos = False
2275
+ if is_continuous :
2276
+ has_same_stopwords_pos = True
2277
+ for qpos , ipos in zip (qspan , ispan ):
2278
+ if qpos not in qkey_span or qpos == qkey_span_end :
2279
+ continue
2280
+
2281
+ if istopwords_by_pos_get (ipos ) != qstopwords_by_pos_get (qpos ):
2282
+ has_same_stopwords_pos = False
2283
+ break
2284
+
2285
+ if not has_same_stopwords_pos :
2286
+ logger_debug (
2287
+ ' ==> DISCARDING, REQUIRED PHRASES PRESENT, BUT STOPWORDS NOT SAME:' ,
2288
+ 'qkey_span:' , qkey_span , 'qpan:' , qspan ,
2289
+ 'istopwords_by_pos:' , istopwords_by_pos ,
2290
+ 'qstopwords_by_pos:' , qstopwords_by_pos
2291
+ )
2292
+
2293
+ is_valid = False
2282
2294
break
2283
2295
2284
- if not has_same_stopwords_pos :
2285
- logger_debug (
2286
- ' ==> DISCARDING, REQUIRED PHRASES PRESENT, BUT STOPWORDS NOT SAME:' ,
2287
- 'qkey_span:' , qkey_span , 'qpan:' , qspan ,
2288
- 'istopwords_by_pos:' , istopwords_by_pos ,
2289
- 'qstopwords_by_pos:' , qstopwords_by_pos
2290
- )
2291
-
2292
- is_valid = False
2293
- break
2294
-
2295
2296
if is_valid :
2296
2297
logger_debug (' ==> KEEPING, REQUIRED PHRASES PRESENT, CONTINUOUS AND NO UNKNOWNS' )
2297
2298
kept_append (match )
2298
2299
else :
2299
2300
match .discard_reason = reason
2300
2301
discarded_append (match )
2301
2302
2303
+ if discarded and not kept :
2304
+ logger_debug (' ==> REINSTATING DISCARDED MISSING REQUIRED PHRASES' )
2305
+
2302
2306
if trace :
2303
2307
print ()
2304
2308
0 commit comments