Spaces:
Sleeping
Sleeping
Download src/lexicon.py from kshitiz14/product_attribute: direct link, hf CLI and curl.
- Browser
- Download file 4.68 kB
-
https://huggingface.co/spaces/kshitiz14/product_attribute/resolve/main/src/lexicon.py
- Command line
-
hf download hf://spaces/kshitiz14/product_attribute/src/lexicon.py
-
curl -L -o lexicon.py https://huggingface.co/spaces/kshitiz14/product_attribute/resolve/main/src/lexicon.py
4.68 kB
| """ | |
| Controlled vocabulary for each attribute type. | |
| Each entry maps a canonical label -> list of surface forms (regex-safe, | |
| lowercase) that should be matched in the input text. This lexicon is used to: | |
| 1. Auto-generate rule-based predictions (the "rules" model). | |
| 2. Define the fixed label space for the trainable ML model | |
| (MultiLabelBinarizer classes_ come straight from these keys). | |
| Colors are handled separately (data-driven, see color_list below) because | |
| color vocabulary is open-ended. | |
| """ | |
| ATTRIBUTE_LEXICON = { | |
| "silhouette": { | |
| "a-line": ["a line", "a-line"], | |
| "ball gown": ["ball gown"], | |
| "mermaid": ["mermaid"], | |
| "sheath": ["sheath"], | |
| "fit-and-flare": ["fit and flare", "fit-and-flare"], | |
| "empire": ["empire waist", "empire"], | |
| "wrap": ["wrap dress", "wrap gown", "wrap"], | |
| "slip": ["slip dress"], | |
| "fitted": ["fitted"], | |
| "trapeze": ["trapeze"], | |
| }, | |
| "fabric": { | |
| "chiffon": ["chiffon"], | |
| "satin": ["satin"], | |
| "lace": ["lace"], | |
| "tulle": ["tulle"], | |
| "velvet": ["velvet"], | |
| "sequin": ["sequin"], | |
| "jersey": ["jersey"], | |
| "glitter": ["glitter"], | |
| "organza": ["organza"], | |
| "taffeta": ["taffeta"], | |
| }, | |
| "neckline": { | |
| "v neckline": ["v neckline", "v-neckline", "v neck", "deep v"], | |
| "sweetheart": ["sweetheart"], | |
| "illusion neckline": ["illusion neckline", "illusion"], | |
| "off shoulder": ["off shoulder", "off-shoulder"], | |
| "one shoulder": ["one shoulder", "one-shoulder"], | |
| "square neckline": ["square neckline", "square neck"], | |
| "halter": ["halter"], | |
| "boat neck": ["boat neck"], | |
| "high neck": ["high neck"], | |
| "cowl neck": ["cowl neck"], | |
| }, | |
| "sleeve": { | |
| "strapless": ["strapless"], | |
| "long sleeves": ["long sleeve"], | |
| "cap sleeves": ["cap sleeve"], | |
| "puff sleeves": ["puff sleeve"], | |
| "three quarter sleeves": ["three quarter sleeve", "3/4 sleeve"], | |
| "flutter sleeves": ["flutter sleeve"], | |
| "illusion sleeves": ["illusion sleeve"], | |
| "off shoulder sleeves": ["off shoulder sleeve", "off-shoulder sleeve"], | |
| "one shoulder sleeve": ["one shoulder sleeve"], | |
| "short sleeves": ["short sleeve"], | |
| "sleeveless": ["sleeveless"], | |
| }, | |
| "length": { | |
| "floor length": ["floor length", "floor-length"], | |
| "sweep train": ["sweep train"], | |
| "chapel train": ["chapel train"], | |
| "cathedral train": ["cathedral train"], | |
| "short": ["short "], | |
| "mini": ["mini"], | |
| "maxi": ["maxi"], | |
| "midi": ["midi"], | |
| "high low": ["high low", "high-low"], | |
| "side slit": ["side slit"], | |
| "high slit": ["high slit", "thigh high slit"], | |
| }, | |
| "embellishment": { | |
| "pleated": ["pleated"], | |
| "beaded": ["beaded", "beading"], | |
| "embroidery": ["embroidery", "embroidered"], | |
| "feather trim": ["feather trim", "feather"], | |
| "ruched": ["ruched", "ruching"], | |
| "corset": ["corset"], | |
| "scalloped hem": ["scalloped hem", "scalloped"], | |
| "draped": ["draped"], | |
| "appliques": ["appliques", "applique"], | |
| "sparkly": ["sparkly"], | |
| "open back": ["open back"], | |
| "lace up back": ["lace up back", "lace-up back"], | |
| "layered": ["layered skirt", "layered"], | |
| }, | |
| "category": { | |
| "bridesmaid dress": ["bridesmaid dress", "bridesmaid gown"], | |
| "prom gown": ["prom gown", "prom dress"], | |
| "wedding dress": ["wedding dress", "bridal gown"], | |
| "cocktail dress": ["cocktail dress"], | |
| "evening gown": ["evening gown"], | |
| "formal dress": ["formal dress"], | |
| "quinceanera dress": ["quinceanera dress", "quinceanera gown"], | |
| "party dress": ["party dress"], | |
| "maternity dress": ["maternity dress", "maternity gown"], | |
| "gown": ["gown"], | |
| "dress": ["dress"], | |
| }, | |
| } | |
| # Fairly common bridal/eveningwear color vocabulary (single & compound terms). | |
| # Longer/compound entries are listed before their substrings so greedy | |
| # matching prefers the more specific phrase (e.g. "dusty blue" over "blue"). | |
| COLOR_VOCAB = [ | |
| "dusty blue", "dusty rose", "sage green", "blush pink", "champagne gold", | |
| "ivory white", "emerald green", "mustard yellow", "cobalt blue", | |
| "ruby red", "rose gold", "wine red", "forest green", "coral pink", | |
| "royal navy", "sage", "blush", "champagne", "ivory", "emerald", "coral", | |
| "burgundy", "lavender", "silver", "gold", "navy", "black", "white", | |
| "red", "pink", "nude", "maroon", "periwinkle", "teal", "turquoise", | |
| "charcoal", "plum", "copper", | |
| ] | |