@@ -94,13 +94,13 @@ def match_foundation_foods(
9494 name_tokens = [IngredientToken (token , tag ) for token , tag in zip (tokens , pos_tags )]
9595
9696 name_tokens = strip_ambiguous_leading_adjectives (name_tokens )
97- logger .debug (f "Matching FDC ingredient for ingredient name tokens: { tokens } " )
97+ logger .debug ("Matching FDC ingredient for ingredient name tokens: %s" , tokens )
9898 prepared_tokens = prepare_tokens (tuple (name_tokens ))
9999 if not prepared_tokens :
100100 logger .debug ("Ingredient name has no tokens valid for matching." )
101101 return None
102102 else :
103- logger .debug (f "Prepared tokens: { prepared_tokens } ." )
103+ logger .debug ("Prepared tokens: %s." , prepared_tokens )
104104
105105 normalised_tokens = normalise_spelling (prepared_tokens )
106106
@@ -158,7 +158,9 @@ def match_foundation_foods(
158158 # Check if both BM25 and uSIF agree on the top result. If they do, return that and
159159 # avoid any further processing.
160160 if fdc := consistent_top_result (bm25_matches , usif_matches ):
161- logger .debug (f"BM25 and uSIF rankers agree on best match: { fdc .fdc_id = } " )
161+ logger .debug (
162+ "BM25 and uSIF rankers agree on best match: fdc.fdc_id=%s" , fdc .fdc_id
163+ )
162164 return FoundationFood (
163165 text = fdc .description ,
164166 confidence = 1.0 ,
@@ -177,12 +179,14 @@ def match_foundation_foods(
177179 m .fdc .fdc_id for m in bm25_matches [:TOP_K ]
178180 }
179181 logger .debug (
180- f"BM25 and uSIF ranker alignment is below threshold "
181- f"({ bm25_usif_agreement = :.4f} < { BM25_USIF_AGREENMENT_THRESHOLD = } )."
182+ "BM25 and uSIF ranker alignment is below threshold "
183+ "(bm25_usif_agreement=%.4f < BM25_USIF_AGREENMENT_THRESHOLD=%f)." ,
184+ bm25_usif_agreement ,
185+ BM25_USIF_AGREENMENT_THRESHOLD ,
182186 )
183187 logger .debug (
184- f "Using FuzzyMatcher on top { TOP_K } matches from "
185- "BM25 and uSIF to help arbitrate."
188+ "Using FuzzyMatcher on top %d matches from BM25 and uSIF to arbitrate." ,
189+ TOP_K ,
186190 )
187191
188192 fuzzy = get_fuzzy_ranker ()
@@ -213,16 +217,17 @@ def match_foundation_foods(
213217 )
214218 if matches_with_top_score > len (DATASET_PREFERENCE ):
215219 logger .debug (
216- f "Top score shared by { matches_with_top_score } FDC entries "
217- "therefore cannot determine suitable match."
220+ "Top score shared by %d FDC entries therefore cannot determine match." ,
221+ matches_with_top_score ,
218222 )
219223 return None
220224
221225 match_quality = determine_match_quality (best_match , usif_matches , fuzzy_matches )
222226 if match_quality .quality == "poor" :
223227 logger .debug (
224- f"Rejected best match of '{ best_match .fdc .description } ' because "
225- f"{ match_quality .reason } ."
228+ "Rejected best match of '%s' because %s." ,
229+ best_match .fdc .description ,
230+ match_quality .reason ,
226231 )
227232 return None
228233
@@ -552,10 +557,10 @@ def fuse_results(
552557 fuzzy_conf = fuzzy_conf / total_conf * 3
553558 usif_conf = usif_conf / total_conf * 3
554559 logger .debug (
555- f "Ranker confidences: "
556- f"BM25= { bm25_conf :.4f } , "
557- f"uSIF= { usif_conf :.4f } , "
558- f"Fuzzy= { fuzzy_conf :.4f } ."
560+ "Ranker confidences: BM25=%.4f, uSIF=%.4f, Fuzzy=%.4f." ,
561+ bm25_conf ,
562+ usif_conf ,
563+ fuzzy_conf ,
559564 )
560565
561566 fused_matches = []
0 commit comments