def is_prediction_valid( product: Product, emb_code: str, ) -> bool: return normalize_emb_code(emb_code) not in [ normalize_emb_code(c) for c in product.emb_codes_tags ]
def already_exists(new_emb_code: str, emb_codes: List[str]) -> bool: emb_codes = [normalize_emb_code(emb_code) for emb_code in emb_codes] normalized_emb_code = normalize_emb_code(new_emb_code) if normalized_emb_code in emb_codes: return True return False
def is_latent( self, insight: ProductInsight, product: Optional[Product] = None ) -> bool: if product is None: product = self.product_store[insight.barcode] product_emb_codes_tags = getattr(product, "emb_codes_tags", []) normalized_emb_code = normalize_emb_code(insight.value) normalized_emb_codes = [normalize_emb_code(c) for c in product_emb_codes_tags] if normalized_emb_code in normalized_emb_codes: return True return False
def is_valid(self, barcode: str, emb_code: str, code_seen: Set[str]) -> bool: product: Optional[Product] = self.product_store[barcode] product_emb_codes_tags = getattr(product, 'emb_codes_tags', []) normalized_emb_code = normalize_emb_code(emb_code) normalized_emb_codes = [ normalize_emb_code(c) for c in product_emb_codes_tags ] if normalized_emb_code in normalized_emb_codes: return False if emb_code in code_seen: return False return True
def is_latent( product: Optional[Product], barcode: str, emb_code: str, code_seen: Set[str], ) -> bool: product_emb_codes_tags = getattr(product, "emb_codes_tags", []) normalized_emb_code = normalize_emb_code(emb_code) normalized_emb_codes = [ normalize_emb_code(c) for c in product_emb_codes_tags ] if normalized_emb_code in normalized_emb_codes: return True if emb_code in code_seen: return True return False