SPB Git

spb/wp37_uqo

Public
1021 B · 14 lines python
1import pandas as pd2from src.matching.match_products import name_key, size_bucket, brand_key, num_tokens, MULTI_RE3from src.cleaning.units import parse_size, size_residual, strip_accents45def test_keys():6    assert brand_key("Häagen-Dazs") == "haagendazs"7    assert name_key("Beurre végétal salé 454 g", "Becel") != name_key("Beurre végétal non salé 454 g", "Becel")8    assert num_tokens(name_key("Lait 2 %", "")) != num_tokens(name_key("Lait 3,25 %", ""))9    a, b = parse_size("12 x 355 ml"), parse_size("6 x 710 ml")10    assert a.qty == b.qty and size_bucket(a.qty, a.base, a.pack) != size_bucket(b.qty, b.base, b.pack)11    assert size_residual("340 g, calibre 21-25") == "21-25 calibre".replace("-", " ") or "calibre" in size_residual("340 g, calibre 21-25")12    assert "cons" not in size_residual("12x355 mL, Cons. 1,20 $/emb.") and size_residual("6x710.0 ml, 0,15 $/100ml") == ""13    assert MULTI_RE.search(strip_accents("BISCUITS DARE WHIPPET OU ULTIME")) and not MULTI_RE.search("Yogourt grec vanille")14
Files · 01c00bc9da6612ba361ac916c22077453a58bb12
Menu

Theme