from __future__ import annotations from crawler_platform.app.adapters.base import DomainAdapter from crawler_platform.app.core.ontology.relation_schema import RelationRule PRODUCT_TYPES = {"Perfume", "Product"} PERFUME_RELATION_RULES: dict[str, RelationRule] = { "hasBrand": RelationRule( "hasBrand", PRODUCT_TYPES, {"Brand"}, page_types={"ProductPage"}, source_zones={"product_title", "product_summary", "product_description", "product_detail"}, min_confidence=0.72, ), "hasTopNote": RelationRule( "hasTopNote", PRODUCT_TYPES, {"Note"}, page_types={"ProductPage"}, source_zones={"product_description", "product_detail"}, min_confidence=0.78, ), "hasMiddleNote": RelationRule( "hasMiddleNote", PRODUCT_TYPES, {"Note"}, page_types={"ProductPage"}, source_zones={"product_description", "product_detail"}, min_confidence=0.78, ), "hasBaseNote": RelationRule( "hasBaseNote", PRODUCT_TYPES, {"Note"}, page_types={"ProductPage"}, source_zones={"product_description", "product_detail"}, min_confidence=0.78, ), "hasAccord": RelationRule( "hasAccord", PRODUCT_TYPES, {"Accord"}, page_types={"ProductPage"}, source_zones={"product_description", "product_detail"}, min_confidence=0.74, ), "evokesMood": RelationRule( "evokesMood", PRODUCT_TYPES, {"Mood"}, page_types={"ProductPage"}, source_zones={"product_description", "product_detail", "review_body"}, min_confidence=0.75, ), "suitableForSeason": RelationRule( "suitableForSeason", PRODUCT_TYPES, {"Season"}, page_types={"ProductPage"}, source_zones={"product_description", "product_detail", "review_body"}, min_confidence=0.75, ), "suitableForOccasion": RelationRule( "suitableForOccasion", PRODUCT_TYPES, {"Occasion"}, page_types={"ProductPage"}, source_zones={"product_description", "product_detail", "review_body"}, min_confidence=0.75, ), "hasReviewKeyword": RelationRule( "hasReviewKeyword", PRODUCT_TYPES, {"Review"}, page_types={"ProductPage", "ReviewPage"}, source_zones={"review_body", "product_description", "product_detail"}, min_confidence=0.78, ), "soldBy": RelationRule( "soldBy", {"Perfume", "Product", "Brand"}, {"Brand"}, page_types={"ProductPage", "BrandStoryPage"}, source_zones={"product_detail", "product_description", "brand_story_body"}, min_confidence=0.82, ), "hasPrice": RelationRule( "hasPrice", PRODUCT_TYPES, literal_value=True, page_types={"ProductPage"}, source_zones={"product_summary", "product_detail"}, min_confidence=0.82, ), "similarTo": RelationRule( "similarTo", PRODUCT_TYPES, PRODUCT_TYPES, page_types={"ProductPage"}, source_zones={"product_description", "product_detail"}, min_confidence=0.86, ), } PERFUME_TYPE_ALIASES = { "perfumeproduct": "Perfume", "fragrance": "Perfume", "product": "Perfume", "fragrancenote": "Note", "ingredient": "Note", "scentnote": "Note", "note": "Note", "brand": "Brand", "accord": "Accord", "mood": "Mood", "season": "Season", "occasion": "Occasion", "reviewkeyword": "Review", "review": "Review", "price": "Price", } PERFUME_NAME_ALIASES = { "Brand": { "forment": "FORMENT", "theforment": "FORMENT", "the forment": "FORMENT", "forment korea": "FORMENT", }, "Note": { "musk": "Musk", "powdery": "Powdery", "floral": "Floral", "citrus": "Citrus", }, "Accord": { "musk": "Musk", "powdery": "Powdery", "floral": "Floral", "citrus": "Citrus", }, "Mood": { "fresh": "Fresh", "cozy": "Cozy", "romantic": "Romantic", "elegant": "Elegant", }, } PERFUME_ADAPTER = DomainAdapter( domain="perfume", relation_rules=PERFUME_RELATION_RULES, entity_type_aliases=PERFUME_TYPE_ALIASES, entity_name_aliases=PERFUME_NAME_ALIASES, )