File size: 2,395 Bytes
83db774 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
from review_patent_substantivity_tuples import mock_review, normalize_decision, tuple_row # noqa: E402
def test_normalize_decision_accepts_only_supported_single_molecule_tuple():
row = {
"patent_id": "US123A1",
"source_locus": "description:10",
"compound_ref_verbatim": "compound 7",
"resolved_cas": "100-52-7",
"resolved_smiles": None,
"measured_value_verbatim": "24 hours",
"units": "hours",
"construct": {
"property_name": "substantivity",
"substrate": ["skin"],
"time_points": ["24 hours"],
},
"verbatim_quote": "Compound 7 (100-52-7) had substantivity on skin for 24 hours.",
"provenance": {"url": "https://patents.google.com/patent/US123A1/en"},
}
poucher = {"100-52-7": {"poucher_coefficient": 1, "tier_band": "top", "all_poucher_names": ["Benzaldehyde"]}}
normalized = normalize_decision(row, mock_review(row), poucher, 0.75, "mock", "mock", 1)
assert normalized["accepted_for_exploratory_tuple_set"] is True
assert normalized["poucher_overlap"]["by_cas"] is True
assert tuple_row(normalized)["measured_value"] == "24 hours"
def test_normalize_decision_rejects_missing_construct_overlap():
row = {
"patent_id": "US123A1",
"source_locus": "description:11",
"verbatim_quote": "Compound 7 is included at 10 to 30 wt% in a fragrance composition.",
"provenance": {},
}
decision = {
"action": "accept",
"single_molecule": True,
"molecule_name": "compound 7",
"cas": None,
"smiles": None,
"measured_property": "other",
"measured_value": "10 to 30 wt%",
"units": "wt%",
"substrate": None,
"timepoint": None,
"method_summary": "Composition loading.",
"construct_overlap_with_poucher": False,
"construct_overlap_reason": "Composition percentage is not olfactive duration.",
"evidence_quote": "10 to 30 wt%",
"confidence": 0.95,
}
normalized = normalize_decision(row, decision, {}, 0.75, "mock", "mock", 1)
assert normalized["accepted_for_exploratory_tuple_set"] is False
assert "no_poucher_construct_overlap" in normalized["validation_errors"]
|