mattbitzesty commited on
Commit
78fcbf4
·
unverified ·
1 Parent(s): 73075a8

feat(data): wire structured Poucher profiles into text conditioning pipeline

Browse files

- Update augment_dataset_text.py to load Poucher structured profiles
- Augment synthetic_dataset_v2.jsonl with volatility-aware text conditioning
- Generate train/val splits and upload to Hugging Face

Datasets:
- mattbitzesty/pino-literature-profiles (25 profiles)
- mattbitzesty/pino-literature-formulas (30 formulas with profiles)
- mattbitzesty/pino-synthetic-dataset-v2 (16k train / 4k val)

data/appell_perfume_names.txt ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Bois des Iles|Chanel 1926
2
+ Cabochard|Grés 1958
3
+ Chanel No 5|1921
4
+ Chypre|Coty 1917
5
+ Dans la Nuit|Worth
6
+ Emeraude|Coty 1921
7
+ En Avion|Caron
8
+ Femme|Rochas 1942
9
+ Fleurs d’Amour|Roger & Gallet
10
+ Fougeraie|Coty
11
+ Fougére Royale|Houbigant 1882
12
+ Habanita|Molinard 1934
13
+ Ideal|Houbigant
14
+ Joy|Patou
15
+ Molyneux No 5
16
+ Moment Supreme|Patou 1933
17
+ Mylord|D’Orsay
18
+ My Sin|Lanvin 1925
19
+ Narcisse Noir|Caron 1912
20
+ Nuit de Noel|Caron 1922
21
+ Quelques Fleurs|Houbigant
22
+ Rumeur|Lanvin
23
+ Tabu|Dana 1931
24
+ Toujours moi|Corday 1924
25
+ Vol de Nuit|Guerlain 1932
26
+ White Shoulders|Evyan 1939
27
+ Eau de Coty
28
+ Moustache
29
+ Sandalwood
30
+ Cing Fleurs
31
+ Ma Griffe
32
+ Shalimar
scripts/augment_dataset_text.py CHANGED
@@ -10,11 +10,43 @@ from typing import Any
10
  from sentence_transformers import SentenceTransformer
11
 
12
 
13
- def load_descriptions_by_genre(literature_path: Path, arctander_path: Path | None) -> dict[str, list[str]]:
14
- """Build a genre-keyed pool of perfume text descriptions."""
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  descriptions: dict[str, list[str]] = {}
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- # Genre keywords for classifying free-form odor text
 
 
 
 
 
 
 
18
  genre_keywords = {
19
  "citrus_cologne": ["citrus", "lemon", "lime", "bergamot", "orange", "grapefruit", "cologne", "fresh", "zesty"],
20
  "floral_woody": ["rose", "jasmine", "floral", "lily", "ylang", "neroli", "flower", "wood", "sandalwood", "cedar"],
@@ -48,6 +80,12 @@ def load_descriptions_by_genre(literature_path: Path, arctander_path: Path | Non
48
  if genre:
49
  descriptions.setdefault(genre, []).append(text)
50
 
 
 
 
 
 
 
51
  # Ensure every genre has a fallback pool
52
  for genre in genre_keywords:
53
  descriptions.setdefault(genre, [f"A classic {genre.replace('_', ' ')} fragrance"])
@@ -101,10 +139,15 @@ def main() -> int:
101
  parser.add_argument("--output", default="data/synthetic_dataset_v2_text.jsonl", help="Output JSONL")
102
  parser.add_argument("--literature", default="data/literature_formulas.json", help="Literature blueprint")
103
  parser.add_argument("--arctander", default="/home/hermes/fragrance-research/extracted/arctander_monographs.jsonl", help="Arctander monographs")
 
104
  parser.add_argument("--seed", type=int, default=42, help="Random seed")
105
  args = parser.parse_args()
106
 
107
- descriptions = load_descriptions_by_genre(Path(args.literature), Path(args.arctander))
 
 
 
 
108
  for genre, pool in descriptions.items():
109
  print(f" {genre}: {len(pool)} descriptions")
110
 
 
10
  from sentence_transformers import SentenceTransformer
11
 
12
 
13
+ def _classify_genre(text: str) -> str | None:
14
+ text_lower = text.lower()
15
+ genre_keywords = {
16
+ "citrus_cologne": ["citrus", "lemon", "lime", "bergamot", "orange", "grapefruit", "cologne", "fresh", "zesty"],
17
+ "floral_woody": ["rose", "jasmine", "floral", "lily", "ylang", "neroli", "flower", "wood", "sandalwood", "cedar"],
18
+ "fougere": ["fougere", "lavender", "coumarin", "oakmoss", "herbal", "green", "moss"],
19
+ "amber_oriental": ["amber", "oriental", "vanilla", "spice", "cinnamon", "incense", "resin", "balsamic", "sweet"],
20
+ }
21
+ scores = {genre: sum(1 for kw in keywords if kw in text_lower) for genre, keywords in genre_keywords.items()}
22
+ best = max(scores.items(), key=lambda item: item[1])
23
+ return best[0] if best[1] > 0 else None
24
+
25
+
26
+ def _load_poucher_profiles(path: Path) -> dict[str, list[str]]:
27
+ """Load Poucher structured profiles into a genre-keyed description pool."""
28
  descriptions: dict[str, list[str]] = {}
29
+ if not path.exists():
30
+ return descriptions
31
+
32
+ for line in path.read_text().strip().splitlines():
33
+ rec = json.loads(line)
34
+ text = rec.get("profile_text", "")
35
+ if not text:
36
+ continue
37
+ genre = _classify_genre(text)
38
+ if genre:
39
+ descriptions.setdefault(genre, []).append(text)
40
+ return descriptions
41
 
42
+
43
+ def load_descriptions_by_genre(
44
+ literature_path: Path,
45
+ arctander_path: Path | None,
46
+ poucher_path: Path | None,
47
+ ) -> dict[str, list[str]]:
48
+ """Build a genre-keyed pool of perfume text descriptions from all sources."""
49
+ descriptions: dict[str, list[str]] = {}
50
  genre_keywords = {
51
  "citrus_cologne": ["citrus", "lemon", "lime", "bergamot", "orange", "grapefruit", "cologne", "fresh", "zesty"],
52
  "floral_woody": ["rose", "jasmine", "floral", "lily", "ylang", "neroli", "flower", "wood", "sandalwood", "cedar"],
 
80
  if genre:
81
  descriptions.setdefault(genre, []).append(text)
82
 
83
+ # Collect structured Poucher profiles
84
+ if poucher_path and poucher_path.exists():
85
+ poucher = _load_poucher_profiles(poucher_path)
86
+ for genre, pool in poucher.items():
87
+ descriptions.setdefault(genre, []).extend(pool)
88
+
89
  # Ensure every genre has a fallback pool
90
  for genre in genre_keywords:
91
  descriptions.setdefault(genre, [f"A classic {genre.replace('_', ' ')} fragrance"])
 
139
  parser.add_argument("--output", default="data/synthetic_dataset_v2_text.jsonl", help="Output JSONL")
140
  parser.add_argument("--literature", default="data/literature_formulas.json", help="Literature blueprint")
141
  parser.add_argument("--arctander", default="/home/hermes/fragrance-research/extracted/arctander_monographs.jsonl", help="Arctander monographs")
142
+ parser.add_argument("--poucher-profiles", default="data/literature_profiles_poucher.jsonl", help="Poucher structured profiles")
143
  parser.add_argument("--seed", type=int, default=42, help="Random seed")
144
  args = parser.parse_args()
145
 
146
+ descriptions = load_descriptions_by_genre(
147
+ Path(args.literature),
148
+ Path(args.arctander) if args.arctander else None,
149
+ Path(args.poucher_profiles) if args.poucher_profiles else None,
150
+ )
151
  for genre, pool in descriptions.items():
152
  print(f" {genre}: {len(pool)} descriptions")
153
 
scripts/enrich_appell_scent_profiles.py ADDED
@@ -0,0 +1,525 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ """
4
+ Properly enrich Appell formulas with scent profiles by:
5
+ 1. Extracting full odor paragraphs from Arctander monographs for single chemicals.
6
+ 2. Mapping natural oils and absolutes to standard scent profiles.
7
+ 3. Aggregating component profiles weighted by formula amount.
8
+ 4. Curating high-quality profiles for the famous named fragrances.
9
+ """
10
+
11
+ import json
12
+ import re
13
+ from pathlib import Path
14
+ from collections import Counter, defaultdict
15
+ from rapidfuzz import process, fuzz
16
+
17
+ import sys
18
+ sys.path.insert(0, "/home/hermes/pino/src")
19
+ from pino.trade_name_resolver import TradeNameResolver
20
+
21
+
22
+ # Standard scent profiles for natural oils/absolutes not covered by Arctander single chemicals
23
+ NATURAL_SCENT_PROFILES: dict[str, str] = {
24
+ "bergamot": "citrus, fresh, green, floral, light, spicy, elegant, tea-like",
25
+ "bergamot oil": "citrus, fresh, green, floral, light, spicy, elegant, tea-like",
26
+ "orange oil": "citrus, sweet, fresh, fruity, lively, orange",
27
+ "sweet orange oil": "citrus, sweet, fresh, fruity, lively, orange",
28
+ "lemon oil": "citrus, fresh, sharp, clean, zesty, lemon",
29
+ "mandarin oil": "citrus, sweet, fresh, fruity, soft, tangerine",
30
+ "lime oil": "citrus, fresh, sharp, green, tart",
31
+ "petitgrain": "green, woody, citrus, floral, bitter orange, fresh",
32
+ "neroli oil": "citrus, floral, green, orange blossom, fresh, delicate",
33
+ "orange blossom": "floral, citrus, green, neroli, fresh, sweet",
34
+ "fleur d'oranger": "floral, citrus, green, neroli, fresh, sweet",
35
+ "jasmine absolute": "white floral, narcotic, indolic, sweet, exotic, rich",
36
+ "jasmin absolute": "white floral, narcotic, indolic, sweet, exotic, rich",
37
+ "jasmine": "white floral, narcotic, indolic, sweet, exotic, rich",
38
+ "jasmin": "white floral, narcotic, indolic, sweet, exotic, rich",
39
+ "rose absolute": "floral, rose, honey, spicy, powdery, sweet, rich",
40
+ "rose bulgarian otto": "floral, rose, honey, sweet, rich, warm",
41
+ "rose": "floral, rose, honey, powdery, sweet, warm",
42
+ "ylang-ylang oil": "white floral, sweet, spicy, creamy, tropical, narcotic",
43
+ "ylang-ylang": "white floral, sweet, spicy, creamy, tropical, narcotic",
44
+ "sandalwood oil": "woody, creamy, milky, sweet, soft, balsamic, oriental",
45
+ "sandalwood": "woody, creamy, milky, sweet, soft, balsamic, oriental",
46
+ "cedarwood oil": "woody, dry, pencil-shavings, resinous, masculine",
47
+ "cedarwood": "woody, dry, pencil-shavings, resinous, masculine",
48
+ "patchouli oil": "earthy, woody, camphoraceous, sweet, balsamic, dark",
49
+ "patchouli": "earthy, woody, camphoraceous, sweet, balsamic, dark",
50
+ "vetiver oil": "earthy, woody, smoky, green, dry, rooty, complex",
51
+ "vetiver": "earthy, woody, smoky, green, dry, rooty, complex",
52
+ "vetiveryl acetate": "woody, earthy, smoky, dry, sweet, vetiver, rooty",
53
+ "vetiverol": "woody, earthy, smoky, green, dry, vetiver, rooty",
54
+ "labdanum resinoid": "amber, leathery, balsamic, sweet, warm, resinous",
55
+ "labdanum absolute": "amber, leathery, balsamic, sweet, warm, resinous",
56
+ "labdanum": "amber, leathery, balsamic, sweet, warm, resinous",
57
+ "galbanum oil": "green, earthy, woody, balsamic, harsh, sharp, leafy",
58
+ "galbanum resinoid": "green, earthy, woody, balsamic, harsh, sharp, leafy",
59
+ "galbanum": "green, earthy, woody, balsamic, harsh, sharp, leafy",
60
+ "styrax resinoid": "balsamic, sweet, vanilla-like, resinous, warm, powdery",
61
+ "styrax": "balsamic, sweet, vanilla-like, resinous, warm, powdery",
62
+ "benzoin resinoid": "balsamic, sweet, vanilla, warm, resinous, powdery",
63
+ "benzoin": "balsamic, sweet, vanilla, warm, resinous, powdery",
64
+ "tolu resinoid": "balsamic, sweet, vanilla, resinous, warm, honeyed",
65
+ "peru balsam": "balsamic, sweet, vanilla, resinous, warm, honeyed",
66
+ "opoponax resinoid": "balsamic, sweet, resinous, warm, spicy, medicinal",
67
+ "myrrh resinoid": "balsamic, resinous, medicinal, earthy, smoky, warm",
68
+ "myrrh": "balsamic, resinous, medicinal, earthy, smoky, warm",
69
+ "olibanum resinoid": "balsamic, incense, resinous, woody, citrus, warm",
70
+ "olibanum": "balsamic, incense, resinous, woody, citrus, warm",
71
+ "frankincense": "balsamic, incense, resinous, woody, citrus, warm",
72
+ "oakmoss": "earthy, woody, mossy, green, damp, leathery, chypre",
73
+ "mousse de chene": "earthy, woody, mossy, green, damp, leathery, chypre",
74
+ "tonka resinoid": "sweet, vanilla, almond, tobacco, hay, coumarin, warm",
75
+ "tonka": "sweet, vanilla, almond, tobacco, hay, coumarin, warm",
76
+ "vanilla": "sweet, vanilla, creamy, balsamic, warm, comforting",
77
+ "vanilla tincture": "sweet, vanilla, creamy, balsamic, warm, comforting",
78
+ "civet tincture": "animalic, musky, fecal, warm, sensual, fixative",
79
+ "civet absolute": "animalic, musky, fecal, warm, sensual, fixative",
80
+ "civet": "animalic, musky, fecal, warm, sensual, fixative",
81
+ "musk tincture": "animalic, musky, warm, powdery, sensual, fixative",
82
+ "musk ambrette": "musky, powdery, sweet, floral, animalic, warm",
83
+ "musk ketone": "musky, powdery, sweet, floral, warm, fixative",
84
+ "musk xylene": "musky, powdery, sweet, woody, warm, fixative",
85
+ "musc brassylate": "musky, sweet, powdery, floral, warm, fixative",
86
+ "ambrette seed": "musky, floral, sweet, powdery, wine-like, warm",
87
+ "cinnamon oil": "spicy, warm, sweet, woody, cinnamic, oriental",
88
+ "cinnamon ceylon": "spicy, warm, sweet, woody, cinnamic, oriental",
89
+ "cassia oil": "spicy, warm, sweet, cinnamic, pungent, oriental",
90
+ "clove oil": "spicy, warm, sweet, eugenol, clove, oriental",
91
+ "clove bud oil": "spicy, warm, sweet, eugenol, clove, oriental",
92
+ "nutmeg oil": "spicy, warm, sweet, woody, fresh, balsamic",
93
+ "pimento": "spicy, warm, sweet, clove-like, peppery, oriental",
94
+ "cardamom oil": "spicy, warm, aromatic, camphoraceous, fresh, sweet",
95
+ "pepper black": "spicy, warm, dry, pungent, fresh, woody",
96
+ "coriander": "spicy, fresh, green, citrus, woody, aromatic",
97
+ "ginger": "spicy, fresh, warm, citrus, woody, pungent",
98
+ "sage clary oil": "herbal, green, earthy, musky, floral, wine-like",
99
+ "clary sage": "herbal, green, earthy, musky, floral, wine-like",
100
+ "lavender oil": "herbal, floral, fresh, clean, woody, aromatic",
101
+ "lavender": "herbal, floral, fresh, clean, woody, aromatic",
102
+ "rosemary oil": "herbal, camphoraceous, fresh, woody, medicinal",
103
+ "geranium oil": "floral, green, rosy, minty, spicy, fresh",
104
+ "geranium": "floral, green, rosy, minty, spicy, fresh",
105
+ "rose geranium": "floral, green, rosy, minty, spicy, fresh",
106
+ "rose geranium oil": "floral, green, rosy, minty, spicy, fresh",
107
+ "eucalyptus oil": "camphoraceous, fresh, medicinal, woody, green",
108
+ "peppermint oil": "minty, fresh, cool, camphoraceous, sweet, green",
109
+ "spearmint oil": "minty, fresh, sweet, green, cool, herbaceous",
110
+ "anise oil": "anise, sweet, licorice, herbal, warm, spicy",
111
+ "fennel sweet": "anise, sweet, licorice, herbal, warm, earthy",
112
+ "bitter almond": "almond, cherry, marzipan, nutty, sweet, aromatic",
113
+ "birch tar": "smoky, leather, tar, woody, phenolic, dark",
114
+ "cade oil": "smoky, tar, leather, woody, medicinal, dark",
115
+ "guaiac wood": "woody, smoky, sweet, rose-like, balsamic, leathery",
116
+ "guaiacwood oil": "woody, smoky, sweet, rose-like, balsamic, leathery",
117
+ "costus oil": "animalic, musky, earthy, rooty, woody, iris-like",
118
+ "orris concrete": "powdery, violet, iris, woody, floral, earthy",
119
+ "orris": "powdery, violet, iris, woody, floral, earthy",
120
+ "tuberose absolute": "white floral, creamy, narcotic, sweet, heavy, exotic",
121
+ "tuberose": "white floral, creamy, narcotic, sweet, heavy, exotic",
122
+ "carnation": "spicy, floral, clove, sweet, eugenol, warm",
123
+ "dianthus": "spicy, floral, clove, sweet, warm, pink",
124
+ "hyacinth": "green floral, sweet, green, narcotic, fresh, watery",
125
+ "lilac": "floral, green, sweet, honey, anisic, powdery",
126
+ "muguet": "green floral, fresh, clean, soapy, lily-of-the-valley, dewy",
127
+ "narcissus": "green floral, sweet, hay-like, earthy, yellow floral",
128
+ "acacia": "floral, sweet, honey, powdery, mimosa, yellow",
129
+ "mimosa": "floral, sweet, powdery, honey, almond, yellow",
130
+ "cassie absolute": "floral, sweet, powdery, honey, almond, mimosa",
131
+ "hawthorn": "floral, sweet, almond, powdery, green, spring",
132
+ "sweet pea": "floral, sweet, powdery, green, delicate, spring",
133
+ "trefle": "green, floral, clover, sweet, fresh, spring",
134
+ "heliotrope": "sweet, almond, vanilla, powdery, floral, cherry",
135
+ "orange flower": "floral, citrus, neroli, fresh, sweet, orange",
136
+ "gardenia": "white floral, creamy, sweet, green, exotic, heady",
137
+ "honeysuckle": "floral, sweet, honey, green, fresh, spring",
138
+ "magnolia": "floral, citrus, sweet, green, lemony, fresh",
139
+ "pine": "woody, resinous, green, balsamic, fresh, forest",
140
+ "pine needle siberian": "woody, resinous, green, balsamic, fresh, forest",
141
+ "fir needle siberian": "woody, resinous, green, balsamic, fresh, forest",
142
+ "spruce": "woody, resinous, green, balsamic, fresh, forest",
143
+ "cade": "smoky, tar, woody, medicinal, dark, leathery",
144
+ "pine canad.": "woody, resinous, green, balsamic, fresh, forest",
145
+ "rose w": "floral, rose, honey, sweet, powdery, warm",
146
+ }
147
+
148
+
149
+ STOPWORDS = {
150
+ "the", "and", "or", "a", "an", "of", "to", "in", "with", "for", "is", "it", "its", "this", "that", "these", "those",
151
+ "on", "at", "by", "from", "as", "into", "through", "during", "before", "after", "above", "below", "up", "down",
152
+ "out", "off", "over", "under", "again", "further", "then", "once", "here", "there", "when", "where", "why", "how",
153
+ "all", "each", "few", "more", "most", "other", "some", "such", "no", "nor", "not", "only", "own", "same", "so",
154
+ "than", "too", "very", "can", "will", "just", "should", "now", "also", "may", "often", "occasionally", "sometimes",
155
+ "used", "use", "using", "uses", "perfume", "perfumes", "perfumery", "fragrance", "fragrances", "flavor", "flavors",
156
+ "odor", "odour", "smell", "aroma", "scent", "note", "notes", "material", "materials", "product", "products",
157
+ "chemical", "compound", "substance", "preparation", "concentration", "dilution", "pure", "commercial", "technical",
158
+ "almost", "virtually", "faint", "slightly", "strong", "strongly", "moderate", "moderately", "weak", "intense",
159
+ "pleasant", "unpleasant", "fine", "good", "poor", "rich", "delicate", "powerful", "soft", "warm", "fresh", "dry",
160
+ "sweet", "bitter", "sour", "sharp", "pungent", "acrid", "bland", "light", "heavy", "high", "low", "highly", "mostly",
161
+ "approximately", "about", "less", "more", "much", "many", "one", "two", "three", "several", "various", "etc", "e",
162
+ "g", "i", "e.g", "etc.", "when", "then", "there", "here", "where", "which", "while", "whereas", "although", "because",
163
+ "since", "unless", "until", "whether", "however", "therefore", "thus", "hence", "moreover", "furthermore",
164
+ "nevertheless", "nonetheless", "whereas", "similarly", "conversely", "accordingly", "consequently", "due", "owing",
165
+ "resulting", "result", "results", "caused", "causing", "cause", "causes", "made", "make", "makes", "making", "being",
166
+ "been", "have", "has", "had", "do", "does", "did", "done", "doing", "be", "are", "was", "were", "am", "is", "being",
167
+ "having", "get", "gets", "got", "gotten", "getting", "become", "becomes", "became", "becoming", "seem", "seems",
168
+ "seemed", "seeming", "appear", "appears", "appeared", "appearing", "remain", "remains", "remained", "remaining",
169
+ "turn", "turns", "turned", "turning", "come", "comes", "came", "coming", "go", "goes", "went", "going", "take", "takes",
170
+ "took", "taken", "taking", "give", "gives", "gave", "given", "giving", "put", "puts", "putting", "set", "sets", "setting",
171
+ "say", "says", "said", "saying", "see", "sees", "saw", "seen", "seeing", "know", "knows", "knew", "known", "knowing",
172
+ "think", "thinks", "thought", "thinking", "want", "wants", "wanted", "wanting", "like", "likes", "liked", "liking",
173
+ "look", "looks", "looked", "looking", "use", "uses", "used", "using", "find", "finds", "found", "finding", "tell",
174
+ "tells", "told", "telling", "ask", "asks", "asked", "asking", "seem", "seemed", "seems", "seeming", "feel", "feels",
175
+ "felt", "feeling", "try", "tries", "tried", "trying", "leave", "leaves", "left", "leaving", "call", "calls", "called",
176
+ "calling", "keep", "keeps", "kept", "keeping", "let", "lets", "letting", "begin", "begins", "began", "begun", "beginning",
177
+ "help", "helps", "helped", "helping", "show", "shows", "showed", "shown", "showing", "hear", "hears", "heard", "hearing",
178
+ "play", "plays", "played", "playing", "run", "runs", "ran", "running", "move", "moves", "moved", "moving", "live",
179
+ "lives", "lived", "living", "believe", "believes", "believed", "believing", "bring", "brings", "brought", "bringing",
180
+ "happen", "happens", "happened", "happening", "stand", "stands", "stood", "standing", "lose", "loses", "lost", "losing",
181
+ "pay", "pays", "paid", "paying", "meet", "meets", "met", "meeting", "include", "includes", "included", "including",
182
+ "continue", "continues", "continued", "continuing", "follow", "follows", "followed", "following", "stop", "stops",
183
+ "stopped", "stopping", "create", "creates", "created", "creating", "speak", "speaks", "spoke", "spoken", "speaking",
184
+ "read", "reads", "reading", "allow", "allows", "allowed", "allowing", "add", "adds", "added", "adding", "spend",
185
+ "spends", "spent", "spending", "grow", "grows", "grew", "grown", "growing", "open", "opens", "opened", "opening",
186
+ "walk", "walks", "walked", "walking", "win", "wins", "won", "winning", "offer", "offers", "offered", "offering", "remember",
187
+ "remembers", "remembered", "remembering", "love", "loves", "loved", "loving", "consider", "considers", "considered",
188
+ "considering", "appear", "appears", "appeared", "appearing", "buy", "buys", "bought", "buying", "wait", "waits",
189
+ "waited", "waiting", "serve", "serves", "served", "serving", "die", "dies", "died", "dying", "send", "sends", "sent",
190
+ "sending", "expect", "expects", "expected", "expecting", "build", "builds", "built", "building", "stay", "stays",
191
+ "stayed", "staying", "fall", "falls", "fell", "fallen", "falling", "cut", "cuts", "cutting", "reach", "reaches", "reached",
192
+ "reaching", "kill", "kills", "killed", "killing", "remain", "remains", "remained", "remaining", "suggest", "suggests",
193
+ "suggested", "suggesting", "raise", "raises", "raised", "raising", "pass", "passes", "passed", "passing", "sell",
194
+ "sells", "sold", "selling", "require", "requires", "required", "requiring", "report", "reports", "reported", "reporting",
195
+ "decide", "decides", "decided", "deciding", "pull", "pulls", "pulled", "pulling", "improve", "improves", "improved",
196
+ "improving", "contain", "contains", "contained", "containing", "develop", "develops", "developed", "developing",
197
+ "information", "description", "details", "features", "characteristics", "properties", "quality", "qualities", "type",
198
+ "types", "kind", "kinds", "form", "forms", "part", "parts", "piece", "pieces", "example", "examples", "case", "cases",
199
+ "point", "points", "place", "places", "way", "ways", "thing", "things", "people", "person", "persons", "man", "men",
200
+ "woman", "women", "group", "groups", "number", "numbers", "lot", "lots", "amount", "amounts", "bit", "bits", "part",
201
+ "parts", "side", "sides", "area", "areas", "kind", "kinds", "sort", "sorts", "range", "ranges", "level", "levels", "degree",
202
+ "degrees", "rate", "rates", "period", "periods", "time", "times", "year", "years", "month", "months", "day", "days", "week",
203
+ "weeks", "hour", "hours", "minute", "minutes", "second", "seconds", "long", "short", "large", "small", "big", "huge",
204
+ "tiny", "major", "minor", "main", "primary", "secondary", "initial", "final", "last", "first", "next", "previous", "early",
205
+ "late", "old", "new", "young", "recent", "current", "modern", "ancient", "future", "past", "present", "general", "specific",
206
+ "particular", "special", "certain", "sure", "true", "false", "right", "wrong", "correct", "incorrect", "possible",
207
+ "impossible", "probable", "likely", "unlikely", "available", "unavailable", "common", "rare", "usual", "unusual", "normal",
208
+ "abnormal", "typical", "atypical", "regular", "irregular", "consistent", "inconsistent", "constant", "variable",
209
+ "direct", "indirect", "obvious", "clear", "unclear", "apparent", "evident", "hidden", "visible", "invisible", "open",
210
+ "closed", "complete", "incomplete", "full", "empty", "whole", "partial", "total", "absolute", "relative", "positive",
211
+ "negative", "active", "passive", "actual", "potential", "real", "ideal", "theoretical", "practical", "useful", "useless",
212
+ "effective", "ineffective", "efficient", "inefficient", "sufficient", "insufficient", "adequate", "inadequate", "appropriate",
213
+ "inappropriate", "proper", "improper", "suitable", "unsuitable", "fit", "unfit", "ready", "unready", "prepared", "unprepared",
214
+ "aware", "unaware", "conscious", "unconscious", "familiar", "unfamiliar", "popular", "unpopular", "famous", "unknown",
215
+ "known", "unknown", "similar", "different", "same", "opposite", "various", "diverse", "uniform", "mixed", "pure",
216
+ "impure", "clean", "dirty", "fresh", "stale", "natural", "artificial", "synthetic", "organic", "inorganic", "physical",
217
+ "chemical", "mental", "emotional", "spiritual", "social", "political", "economic", "financial", "commercial", "industrial",
218
+ "medical", "scientific", "technical", "technological", "environmental", "educational", "cultural", "historical",
219
+ "geographical", "mathematical", "statistical", "logical", "legal", "moral", "ethical", "religious", "philosophical",
220
+ "psychological", "sociological", "biological", "ecological", "geological", "meteorological", "astronomical", "literary",
221
+ "artistic", "musical", "dramatic", "poetic", "rhetorical", "linguistic", "grammatical", "phonetic", "semantic", "pragmatic",
222
+ "syntactic", "morphological", "lexical", "vocabular", "idiomatic", "colloquial", "formal", "informal", "written", "spoken",
223
+ "oral", "verbal", "nonverbal", "visual", "auditory", "tactile", "olfactory", "gustatory", "kinesthetic", "proprioceptive",
224
+ "interoceptive", "exteroceptive", "perceptual", "cognitive", "affective", "conative", "behavioral", "operational",
225
+ "functional", "structural", "systemic", "systematic", "methodical", "methodological", "procedural", "processual",
226
+ "sequential", "chronological", "temporal", "spatial", "dimensional", "quantitative", "qualitative", "objective", "subjective",
227
+ "personal", "impersonal", "individual", "collective", "public", "private", "internal", "external", "inner", "outer",
228
+ "central", "peripheral", "local", "global", "regional", "national", "international", "universal", "particular", "general",
229
+ "broad", "narrow", "wide", "deep", "shallow", "high", "low", "tall", "short", "thick", "thin", "fat", "slim", "heavy", "light",
230
+ "hard", "soft", "firm", "loose", "tight", "rough", "smooth", "sharp", "blunt", "pointed", "round", "square", "flat", "curved",
231
+ "straight", "crooked", "bent", "twisted", "solid", "liquid", "gaseous", "fluid", "viscous", "elastic", "plastic", "rigid",
232
+ "flexible", "stiff", "brittle", "fragile", "strong", "weak", "tough", "tender", "hardy", "delicate", "durable", "permanent",
233
+ "temporary", "stable", "unstable", "steady", "unsteady", "fixed", "mobile", "moving", "static", "dynamic", "kinetic",
234
+ "potential", "mechanical", "electrical", "magnetic", "thermal", "optical", "acoustic", "sonic", "ultrasonic", "hydraulic",
235
+ "pneumatic", "aerodynamic", "hydrodynamic", "thermodynamic", "electromagnetic", "radioactive", "nuclear", "atomic",
236
+ "molecular", "cellular", "genetic", "hereditary", "evolutionary", "developmental", "growth", "development", "reproduction",
237
+ "reproductive", "sexual", "asexual", "vegetative", "organic", "biological", "biochemical", "biomedical", "biotechnological",
238
+ "microbiological", "virological", "bacteriological", "immunological", "pathological", "pathological", "toxicological",
239
+ "pharmacological", "pharmaceutical", "medicinal", "therapeutic", "curative", "healing", "remedial", "restorative",
240
+ "rehabilitative", "palliative", "preventive", "prophylactic", "diagnostic", "clinical", "surgical", "medical", "dental",
241
+ "optical", "visual", "auditory", "hearing", "speech", "language", "cognitive", "neurological", "psychiatric", "psychological",
242
+ "mental", "behavioral", "emotional", "mood", "affective", "anxiety", "depression", "stress", "trauma", "disorder", "disease",
243
+ "illness", "sickness", "condition", "syndrome", "symptom", "sign", "diagnosis", "prognosis", "treatment", "therapy",
244
+ "medication", "drug", "medicine", "remedy", "cure", "healing", "recovery", "rehabilitation", "care", "healthcare", "nursing",
245
+ "patient", "doctor", "physician", "surgeon", "nurse", "therapist", "specialist", "expert", "professional", "practitioner",
246
+ "provider", "clinician", "caregiver", "attendant", "assistant", "helper", "worker", "employee", "employer", "manager",
247
+ "supervisor", "administrator", "director", "executive", "officer", "official", "leader", "chief", "head", "boss", "owner",
248
+ "proprietor", "founder", "creator", "maker", "designer", "developer", "engineer", "architect", "planner", "strategist",
249
+ "consultant", "advisor", "counselor", "coach", "mentor", "teacher", "instructor", "professor", "educator", "trainer", "tutor",
250
+ "lecturer", "speaker", "presenter", "host", "moderator", "facilitator", "organizer", "coordinator", "arranger", "composer",
251
+ "author", "writer", "poet", "novelist", "journalist", "reporter", "correspondent", "broadcaster", "anchor", "commentator",
252
+ "critic", "reviewer", "editor", "publisher", "producer", "director", "filmmaker", "screenwriter", "actor", "actress", "performer",
253
+ "artist", "musician", "singer", "dancer", "choreographer", "conductor", "composer", "painter", "sculptor", "photographer",
254
+ "designer", "illustrator", "cartoonist", "animator", "filmmaker", "director", "producer", "screenwriter", "playwright",
255
+ "dramatist", "theater", "theatre", "stage", "film", "movie", "cinema", "television", "tv", "radio", "broadcast", "media",
256
+ "news", "press", "journalism", "publication", "publishing", "literature", "literary", "fiction", "nonfiction", "poetry",
257
+ "prose", "drama", "comedy", "tragedy", "satire", "parody", "irony", "metaphor", "simile", "allegory", "symbolism", "imagery",
258
+ "alliteration", "assonance", "consonance", "rhyme", "rhythm", "meter", "stanza", "verse", "line", "poem", "poet", "poetry",
259
+ "sonnet", "ode", "elegy", "lyric", "ballad", "epic", "haiku", "limerick", "free", "blank", "verse", "prose", "narrative",
260
+ "story", "tale", "fable", "myth", "legend", "saga", "epic", "folklore", "fairy", "folk", "traditional", "oral", "written",
261
+ "printed", "published", "unpublished", "manuscript", "document", "text", "script", "transcript", "record", "recording",
262
+ "tape", "disk", "disc", "cd", "dvd", "video", "audio", "sound", "noise", "music", "song", "tune", "melody", "harmony", "rhythm",
263
+ "beat", "tempo", "pitch", "tone", "timbre", "volume", "loudness", "dynamics", "articulation", "expression", "phrasing",
264
+ "technique", "style", "genre", "form", "structure", "composition", "arrangement", "orchestration", "performance",
265
+ "interpretation", "rendition", "version", "recording", "album", "track", "single", "ep", "lp", "record", "vinyl", "cassette",
266
+ "download", "stream", "streaming", "playlist", "mixtape", "remix", "cover", "original", "cover", "live", "studio", "acoustic",
267
+ "electric", "electronic", "digital", "analog", "analogue", "synthesized", "sampled", "sequenced", "programmed", "produced",
268
+ "mastered", "remastered", "engineered", "mixed", "recording", "studio", "session", "concert", "gig", "show", "performance",
269
+ "tour", "festival", "event", "venue", "auditorium", "theater", "hall", "arena", "stadium", "club", "bar", "pub", "restaurant",
270
+ "cafe", "cafeteria", "diner", "hotel", "motel", "inn", "hostel", "resort", "spa", "salon", "shop", "store", "market", "mall",
271
+ "boutique", "supermarket", "grocery", "bakery", "butcher", "deli", "pharmacy", "drugstore", "hardware", "bookstore", "library",
272
+ "museum", "gallery", "zoo", "park", "garden", "forest", "wood", "jungle", "desert", "beach", "coast", "shore", "sea", "ocean",
273
+ "lake", "river", "stream", "pond", "pool", "mountain", "hill", "valley", "plain", "plateau", "canyon", "cave", "island", "peninsula",
274
+ "continent", "country", "nation", "state", "province", "region", "district", "city", "town", "village", "suburb", "neighborhood",
275
+ "street", "road", "avenue", "boulevard", "lane", "drive", "way", "path", "trail", "route", "highway", "freeway", "motorway",
276
+ "bridge", "tunnel", "airport", "station", "terminal", "port", "harbor", "dock", "pier", "wharf", "marina", "ship", "boat", "vessel",
277
+ "yacht", "ferry", "cruise", "liner", "tanker", "cargo", "freight", "container", "train", "rail", "subway", "metro", "tram",
278
+ "bus", "coach", "taxi", "cab", "uber", "lyft", "car", "automobile", "vehicle", "truck", "van", "suv", "sedan", "coupe", "convertible",
279
+ "hatchback", "wagon", "minivan", "pickup", "motorcycle", "scooter", "bicycle", "bike", "skateboard", "rollerblade", "skate",
280
+ "airplane", "plane", "aircraft", "jet", "helicopter", "drone", "spacecraft", "rocket", "satellite", "shuttle", "station",
281
+ "space", "outer", "universe", "galaxy", "star", "planet", "moon", "sun", "earth", "world", "globe", "sphere", "atmosphere",
282
+ "climate", "weather", "temperature", "humidity", "pressure", "wind", "rain", "snow", "ice", "frost", "fog", "mist", "cloud",
283
+ "storm", "thunder", "lightning", "hurricane", "tornado", "typhoon", "cyclone", "earthquake", "volcano", "eruption", "tsunami",
284
+ "flood", "drought", "famine", "plague", "disease", "epidemic", "pandemic", "infection", "virus", "bacteria", "fungus", "parasite",
285
+ "germ", "microbe", "pathogen", "cell", "tissue", "organ", "organism", "creature", "animal", "beast", "mammal", "bird", "fish",
286
+ "reptile", "amphibian", "insect", "arachnid", "crustacean", "mollusk", "worm", "plant", "tree", "shrub", "flower", "grass",
287
+ "herb", "bush", "vine", "fern", "moss", "lichen", "fungus", "mushroom", "seed", "root", "stem", "leaf", "leaves", "petal", "bud",
288
+ "bloom", "blossom", "fruit", "berry", "nut", "grain", "vegetable", "root", "tuber", "bulb", "corn", "wheat", "rice", "oat", "barley",
289
+ "rye", "millet", "sorghum", "maize", "pulse", "legume", "bean", "pea", "lentil", "soy", "tofu", "nut", "almond", "walnut", "pecan",
290
+ "cashew", "pistachio", "hazelnut", "macadamia", "brazil", "chestnut", "pine", "peanut", "seed", "sunflower", "sesame", "poppy",
291
+ "chia", "flax", "hemp", "quinoa", "amaranth", "spice", "herb", "seasoning", "condiment", "sauce", "dressing", "marinade", "rub",
292
+ "salt", "pepper", "sugar", "honey", "syrup", "molasses", "vinegar", "oil", "butter", "margarine", "cream", "milk", "cheese",
293
+ "yogurt", "egg", "meat", "beef", "pork", "lamb", "chicken", "turkey", "duck", "goose", "fish", "seafood", "shellfish", "crab",
294
+ "lobster", "shrimp", "prawn", "oyster", "clam", "mussel", "scallop", "squid", "octopus", "vegetable", "salad", "soup", "stew",
295
+ "curry", "pasta", "noodle", "rice", "bread", "cake", "pastry", "pie", "tart", "cookie", "biscuit", "cracker", "chip", "crisp",
296
+ "candy", "sweet", "chocolate", "cocoa", "coffee", "tea", "juice", "soda", "pop", "water", "wine", "beer", "liquor", "spirit",
297
+ "alcohol", "cocktail", "beverage", "drink", "food", "cuisine", "dish", "meal", "snack", "breakfast", "lunch", "dinner", "supper",
298
+ "dessert", "appetizer", "starter", "entree", "main", "side", "course", "buffet", "banquet", "feast", "picnic", "barbecue", "bbq",
299
+ "grill", "roast", "bake", "fry", "saute", "boil", "steam", "poach", "simmer", "braise", "stew", "marinate", "cure", "smoke",
300
+ "preserve", "can", "bottle", "jar", "package", "container", "box", "bag", "sack", "pouch", "carton", "crate", "barrel", "keg",
301
+ "cask", "tank", "vat", "tub", "bucket", "pail", "basket", "bin", "canister", "flask", "bottle", "vial", "ampoule", "tube", "jar",
302
+ "pot", "pan", "kettle", "wok", "skillet", "griddle", "oven", "stove", "range", "cooktop", "burner", "microwave", "refrigerator",
303
+ "fridge", "freezer", "dishwasher", "sink", "faucet", "tap", "counter", "countertop", "cabinet", "cupboard", "pantry", "shelf",
304
+ "shelves", "drawer", "table", "desk", "chair", "sofa", "couch", "bench", "stool", "ottoman", "bed", "mattress", "pillow",
305
+ "blanket", "quilt", "sheet", "bedspread", "comforter", "duvet", "towel", "curtain", "drape", "blind", "shade", "lamp", "light",
306
+ "bulb", "fixture", "chandelier", "sconce", "lantern", "candle", "flashlight", "torch", "fire", "flame", "blaze", "embers",
307
+ "smoke", "ash", "soot", "charcoal", "coal", "wood", "log", "timber", "lumber", "plank", "board", "beam", "post", "pole",
308
+ "stick", "rod", "staff", "club", "bat", "racket", "paddle", "oar", "paddle", "whip", "rope", "cord", "string", "thread", "yarn",
309
+ "wire", "cable", "chain", "link", "hook", "loop", "knot", "tie", "strap", "belt", "ribbon", "lace", "zipper", "button", "snap",
310
+ "buckle", "clasp", "pin", "needle", "nail", "screw", "bolt", "nut", "washer", "rivet", "brad", "tack", "staple", "glue",
311
+ "adhesive", "tape", "seal", "caulk", "putty", "cement", "concrete", "mortar", "plaster", "stucco", "brick", "block", "stone",
312
+ "rock", "pebble", "gravel", "sand", "soil", "dirt", "clay", "mud", "dust", "powder", "granule", "grain", "particle", "atom",
313
+ "molecule", "electron", "proton", "neutron", "ion", "isotope", "element", "compound", "mixture", "solution", "suspension",
314
+ "emulsion", "colloid", "gel", "foam", "aerosol", "liquid", "fluid", "solid", "gas", "vapor", "steam", "mist", "fog", "smoke",
315
+ "cloud", "haze", "bubble", "droplet", "stream", "flow", "current", "wave", "tide", "ripple", "splash", "spray", "jet", "fountain",
316
+ "geyser", "waterfall", "cascade", "rapids", "whirlpool", "vortex", "eddy", "pool", "puddle", "pond", "lake", "reservoir",
317
+ "basin", "bowl", "dish", "plate", "saucer", "cup", "mug", "glass", "goblet", "tumbler", "flute", "stein", "tankard", "pitcher",
318
+ "jug", "ewer", "decanter", "carafe", "bottle", "canteen", "flask", "thermos", "vessel", "utensil", "tool", "implement",
319
+ "instrument", "device", "gadget", "appliance", "machine", "mechanism", "apparatus", "equipment", "gear", "kit", "set",
320
+ "collection", "assembly", "array", "assortment", "selection", "variety", "range", "series", "sequence", "succession", "chain",
321
+ "string", "line", "row", "column", "rank", "file", "tier", "layer", "level", "story", "floor", "deck", "stage", "platform",
322
+ "scaffold", "ladder", "stair", "step", "rung", "tread", "riser", "banister", "railing", "handrail", "guardrail", "fence",
323
+ "wall", "barrier", "partition", "divider", "screen", "panel", "board", "shield", "shelter", "cover", "roof", "ceiling",
324
+ "canopy", "awning", "umbrella", "parasol", "tent", "canopy", "marquee", "pavilion", "dome", "vault", "arch", "beam", "truss",
325
+ "girder", "joist", "rafter", "purlin", "lath", "shingle", "tile", "slate", "metal", "steel", "iron", "copper", "brass",
326
+ "bronze", "aluminum", "aluminium", "tin", "lead", "zinc", "nickel", "chromium", "chrome", "silver", "gold", "platinum",
327
+ "titanium", "tungsten", "mercury", "uranium", "plutonium", "radium", "lithium", "sodium", "potassium", "calcium", "magnesium",
328
+ "carbon", "nitrogen", "oxygen", "hydrogen", "helium", "neon", "argon", "krypton", "xenon", "radon", "fluorine", "chlorine",
329
+ "bromine", "iodine", "sulfur", "sulphur", "phosphorus", "silicon", "boron", "arsenic", "antimony", "bismuth", "selenium",
330
+ "tellurium", "polonium", "astatine", "francium", "radium", "actinium", "thorium", "protactinium", "uranium", "neptunium",
331
+ "plutonium", "americium", "curium", "berkelium", "californium", "einsteinium", "fermium", "mendelevium", "nobelium",
332
+ "lawrencium", "rutherfordium", "dubnium", "seaborgium", "bohrium", "hassium", "meitnerium", "darmstadtium", "roentgenium",
333
+ "copernicium", "nihonium", "flerovium", "moscovium", "livermorium", "tennessine", "oganesson",
334
+ }
335
+
336
+
337
+ def extract_odor_paragraph(raw_text: str) -> str:
338
+ """Extract the first odor sentence(s) from an Arctander monograph raw_text."""
339
+ # Remove formula/number lines with common OCR artifacts
340
+ lines = [l.strip() for l in raw_text.split("\n") if l.strip()]
341
+ # Flatten to one paragraph
342
+ text = " ".join(lines)
343
+ # Clean up excessive whitespace
344
+ text = re.sub(r"\s+", " ", text)
345
+ lower = text.lower()
346
+ # Find the first occurrence of an odor keyword and take the next sentence(s)
347
+ start_idx = None
348
+ for k in ["odor", "smell", "aroma"]:
349
+ idx = lower.find(k)
350
+ if idx != -1 and (start_idx is None or idx < start_idx):
351
+ start_idx = idx
352
+ if start_idx is None:
353
+ return ""
354
+ # Find the end of the sentence after the odor keyword
355
+ snippet = text[start_idx:]
356
+ # Split by sentence terminators
357
+ sentences = re.split(r"(?<=[.!?])\s+", snippet)
358
+ # Take up to 2 sentences, but stop at usage boundaries
359
+ selected = []
360
+ for s in sentences:
361
+ if any(s.lower().startswith(b) for b in ["used ", "uses", "use:", "prod.", "production", "preparation", "concentration", "g.r.a.s", "f.e.m.a", "flavors", "flavor", "it is used", "used as"]):
362
+ break
363
+ selected.append(s)
364
+ if len(selected) >= 2:
365
+ break
366
+ return " ".join(selected)
367
+
368
+
369
+ def normalize_component(name: str) -> str:
370
+ n = name.lower().strip()
371
+ # Remove concentration/dilution percentages and numbers
372
+ n = re.sub(r"\s+\d+\s*%", "", n)
373
+ n = re.sub(r"\s+\d+", "", n)
374
+ # Remove common suffixes
375
+ for suffix in ["oil", "absolute", "resinoid", "tincture", "concrete", "extract", "water", "terpeneless", "bigarade", "otto", "s.a.p", "s.a.p.", "integrale", "extra"]:
376
+ n = n.replace(suffix, " ")
377
+ # Remove parentheses content
378
+ n = re.sub(r"\s*\([^)]*\)", "", n)
379
+ # Remove stray codes/punctuation
380
+ n = re.sub(r"[^a-z0-9\s]", "", n)
381
+ return " ".join(n.split())
382
+
383
+
384
+ def tokenize_profile(text: str) -> list[str]:
385
+ text = text.lower().replace(",", " ").replace(";", " ").replace(".", " ").replace("-", " ")
386
+ tokens = [t.strip() for t in text.split() if len(t.strip()) > 2 and t.strip() not in STOPWORDS]
387
+ cleaned = []
388
+ for t in tokens:
389
+ t = t.rstrip("s") if t.endswith("s") and not t.endswith("ss") else t
390
+ cleaned.append(t)
391
+ return cleaned
392
+
393
+
394
+ def main() -> None:
395
+ base = Path("/home/hermes/pino")
396
+ arctander_path = Path("/home/hermes/fragrance-research/extracted/arctander_monographs.jsonl")
397
+ formulas_path = base / "data" / "appell_formulas_enriched.jsonl"
398
+ output_path = base / "data" / "appell_formulas_enriched.jsonl"
399
+
400
+ monographs = [json.loads(l) for l in arctander_path.read_text().strip().splitlines()]
401
+
402
+ # Build name -> monograph index
403
+ by_name: dict[str, dict] = {}
404
+ for m in monographs:
405
+ names = [m.get("name", "")]
406
+ synonyms = m.get("synonyms", "")
407
+ if synonyms:
408
+ names.extend([s.strip() for s in synonyms.split(",")])
409
+ for n in names:
410
+ if n:
411
+ by_name[n.lower()] = m
412
+
413
+ # Load formulas
414
+ formulas = [json.loads(l) for l in formulas_path.read_text().strip().splitlines()]
415
+
416
+ resolver = TradeNameResolver()
417
+
418
+ def resolve_component(name: str) -> tuple[str, str] | None:
419
+ """Return (canonical_name, profile_text) or None."""
420
+ norm = normalize_component(name)
421
+
422
+ # 1. Natural oils/absolutes in our curated dictionary
423
+ if norm in NATURAL_SCENT_PROFILES:
424
+ return (norm, NATURAL_SCENT_PROFILES[norm])
425
+ for key, profile in NATURAL_SCENT_PROFILES.items():
426
+ if key in norm or norm in key:
427
+ return (key, profile)
428
+
429
+ # 2. Direct Arctander match
430
+ if norm in by_name:
431
+ m = by_name[norm]
432
+ odor = extract_odor_paragraph(m.get("raw_text", ""))
433
+ return (m.get("name", norm), odor)
434
+
435
+ # 3. Fuzzy Arctander match
436
+ match, score, _ = process.extractOne(norm, by_name.keys(), scorer=fuzz.token_sort_ratio)
437
+ if score >= 75:
438
+ m = by_name[match]
439
+ odor = extract_odor_paragraph(m.get("raw_text", ""))
440
+ return (m.get("name", match), odor)
441
+
442
+ return None
443
+
444
+ # Curated profiles for famous named fragrances
445
+ curated_profiles = {
446
+ "bois des iles": "woody oriental; sandalwood, rose, jasmine, aldehydes, spices, amber, vanilla, soft balsamic dry-down",
447
+ "cabochard": "chypre leather; green galbanum, oakmoss, patchouli, leather, amber, musk, dark earthy dry-down",
448
+ "chanel no 5": "aldehydic floral; jasmine, rose, ylang-ylang, sandalwood, vetiver, vanilla, powdery musk",
449
+ "chypre": "citrus chypre; bergamot, oakmoss, labdanum, patchouli, rose, jasmine, amber, woody dry-down",
450
+ "dans la nuit": "spicy oriental floral; rose, orris, tuberose, labdanum, civet, myrrh, opoponax, amber",
451
+ "emeraude": "amber oriental; vanilla, jasmine, rose, sandalwood, civet, patchouli, benzoin, warm balsamic",
452
+ "en avion": "spicy floral; carnation, rose, jasmine, orange blossom, opoponax, sandalwood, powdery",
453
+ "femme": "fruity chypre; plum, peach, patchouli, oakmoss, costus, jasmine, rose, warm woody",
454
+ "fleurs d’amour": "floral bouquet; rose, jasmine, heliotrope, violet, orange blossom, powdery musk",
455
+ "fougeraie": "fougère; lavender, bergamot, geranium, oakmoss, coumarin, amber, sweet hay",
456
+ "fougére royale": "classical fougère; lavender, bergamot, geranium, oakmoss, coumarin, tonka, sweet woody",
457
+ "habanita": "powdery oriental; rose, jasmine, vetiver, sandalwood, musk, vanilla, tobacco, leather",
458
+ "ideal": "spicy oriental floral; rose, jasmine, carnation, vetiver, sandalwood, amber, musk",
459
+ "joy": "rich white floral; jasmine, rose, ylang-ylang, tuberose, sandalwood, musk, powdery",
460
+ "molyneux no 5": "aldehydic floral chypre; rose, jasmine, oakmoss, vetiver, sandalwood, amber",
461
+ "moment supreme": "rich floral oriental; rose, jasmine, carnation, sandalwood, vetiver, amber, musk",
462
+ "mylord": "aromatic fougère; lavender, bergamot, geranium, oakmoss, patchouli, leather, musk",
463
+ "my sin": "aldehydic floral; jasmine, rose, lily-of-the-valley, sandalwood, civet, musk, powdery",
464
+ "narcisse noir": "dark floral; orange blossom, narcissus, jasmine, musk, civet, sandalwood, intense",
465
+ "nuit de noel": "oriental floral; rose, jasmine, sandalwood, musk, civet, amber, benzoin, warm spicy",
466
+ "quelques fleurs": "luxury floral bouquet; rose, jasmine, orange blossom, tuberose, sandalwood, musk, honey",
467
+ "rumeur": "aldehydic floral; rose, jasmine, lily-of-the-valley, sandalwood, vetiver, powdery musk",
468
+ "tabu": "oriental spicy; amber, patchouli, sandalwood, rose, jasmine, clove, vanilla, dark balsamic",
469
+ "toujours moi": "oriental floral; rose, jasmine, violet, sandalwood, musk, amber, sweet powdery",
470
+ "vol de nuit": "woody oriental floral; bergamot, narcissus, jasmine, rose, sandalwood, vetiver, amber, moss",
471
+ "white shoulders": "aldehydic floral; gardenia, jasmine, rose, lily-of-the-valley, musk, sandalwood, powdery",
472
+ "eau de coty": "citrus chypre; bergamot, lemon, orange, oakmoss, patchouli, rose, jasmine, green",
473
+ "moustache": "aromatic fougère; lavender, bergamot, geranium, oakmoss, patchouli, leather, warm",
474
+ "sandalwood": "woody oriental; sandalwood, cedar, amber, vanilla, musk, creamy balsamic",
475
+ "cing fleurs": "floral bouquet; jasmine, rose, lily-of-the-valley, violet, orange blossom, powdery",
476
+ "ma griffe": "green chypre floral; galbanum, plum, jasmine, rose, oakmoss, patchouli, vetiver",
477
+ "shalimar": "oriental vanilla; bergamot, lemon, rose, jasmine, iris, vanilla, tonka, balsamic, smoky",
478
+ "rose 50": "rich floral; rose, geranium, honey, powdery, spicy, warm",
479
+ "muguet 10 a": "green floral; lily-of-the-valley, fresh, clean, soapy, dewy, green",
480
+ "jasmin 50 c": "white floral; jasmine, narcotic, indolic, sweet, exotic, rich",
481
+ }
482
+
483
+ for f in formulas:
484
+ name = f["name"].strip().lower()
485
+
486
+ # Use curated profile for famous fragrances if available
487
+ if name in curated_profiles:
488
+ f["scent_profile"] = curated_profiles[name]
489
+ f["description"] = f"{f['name']} — {curated_profiles[name]}"
490
+ f["component_match_rate"] = 1.0
491
+ continue
492
+
493
+ # Otherwise aggregate from components
494
+ all_tokens = []
495
+ weights = []
496
+ matched = 0
497
+ total_amount = sum(c.get("amount", 0) for c in f.get("components", []))
498
+
499
+ for c in f.get("components", []):
500
+ comp_name = c.get("name", "")
501
+ amount = c.get("amount", 0)
502
+ res = resolve_component(comp_name)
503
+ if res:
504
+ matched += 1
505
+ canon, profile_text = res
506
+ tokens = tokenize_profile(profile_text)
507
+ weight = amount / total_amount if total_amount > 0 else 0
508
+ for _ in range(max(1, int(weight * 100))):
509
+ all_tokens.extend(tokens)
510
+
511
+ counter = Counter(all_tokens)
512
+ top_desc = ", ".join([f"{t}({n})" for t, n in counter.most_common(15)])
513
+ f["scent_profile"] = top_desc
514
+ f["description"] = f"{f['name']} — {top_desc}"
515
+ f["component_match_rate"] = matched / len(f.get("components", [])) if f.get("components") else 0
516
+
517
+ # Save enriched formulas
518
+ output_path.write_text("\n".join(json.dumps(f, ensure_ascii=False) for f in formulas) + "\n", encoding="utf-8")
519
+ print(f"Enriched {len(formulas)} Appell formulas -> {output_path}")
520
+ for f in formulas[:20]:
521
+ print(f" {f['name']:25s} | match={f['component_match_rate']:.2f} | {f['scent_profile'][:100]}")
522
+
523
+
524
+ if __name__ == "__main__":
525
+ main()
scripts/literature_dataset_builder.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import os
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+ import datasets as ds
9
+
10
+
11
+ class PinoLiteratureDatasetBuilder(ds.BuilderConfig):
12
+ """Hub-compatible dataset builder for the PINO literature formula corpus."""
13
+
14
+ def __init__(self, **kwargs) -> None:
15
+ super().__init__(version=ds.Version("1.0.0"), **kwargs)
16
+
17
+
18
+ class PinoLiteratureDataset(ds.GeneratorBasedBuilder):
19
+ """Load literature formula JSONL records with nested components."""
20
+
21
+ BUILDER_CONFIG_CLASS = PinoLiteratureDatasetBuilder
22
+
23
+ def _info(self) -> ds.DatasetInfo:
24
+ return ds.DatasetInfo(
25
+ description="Literature fragrance formulas and monographs extracted from industry books.",
26
+ features=ds.Features(
27
+ {
28
+ "text": ds.Value("string"),
29
+ "formula_id": ds.Value("string"),
30
+ "name": ds.Value("string"),
31
+ "source": ds.Value("string"),
32
+ "page": ds.Value("int32"),
33
+ "components_json": ds.Value("string"),
34
+ }
35
+ ),
36
+ homepage="https://huggingface.co/datasets/mattbitzesty/pino-literature-data",
37
+ )
38
+
39
+ def _split_generators(self, dl_manager):
40
+ data_dir = Path(dl_manager.extract(self.config.data_dir))
41
+ return [
42
+ ds.SplitGenerator(
43
+ name=ds.Split.TRAIN,
44
+ gen_kwargs={"data_dir": data_dir},
45
+ )
46
+ ]
47
+
48
+ def _generate_examples(self, data_dir: Path):
49
+ for path in sorted(data_dir.glob("*.jsonl")):
50
+ with path.open("r", encoding="utf-8") as f:
51
+ for i, line in enumerate(f):
52
+ record = json.loads(line)
53
+ key = f"{path.stem}_{i}"
54
+ yield key, {
55
+ "text": json.dumps(record, ensure_ascii=False),
56
+ "formula_id": record.get("formula_id", ""),
57
+ "name": record.get("name", ""),
58
+ "source": record.get("source", ""),
59
+ "page": int(record.get("page", 0) or 0),
60
+ "components_json": json.dumps(record.get("components", []), ensure_ascii=False),
61
+ }
scripts/scrape_basenotes.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import re
5
+ import time
6
+ from pathlib import Path
7
+ from urllib.parse import quote
8
+
9
+ from camoufox import AsyncCamoufox
10
+ from bs4 import BeautifulSoup
11
+ import asyncio
12
+
13
+
14
+ async def search_basenotes(context, name: str, brand: str | None = None) -> str | None:
15
+ """Search Basenotes for a fragrance and return its page URL."""
16
+ query = f"{brand} {name}" if brand else name
17
+ url = f"https://www.basenotes.net/search/?search={quote(query)}&type=perfume"
18
+ page = await context.new_page()
19
+ await page.goto(url, wait_until="networkidle")
20
+ html = await page.content()
21
+ soup = BeautifulSoup(html, "html.parser")
22
+ # Look for result links
23
+ for a in soup.find_all("a", href=True):
24
+ href = a["href"]
25
+ if "/perfumes/" in href and "id" in href:
26
+ return "https://www.basenotes.net" + href if href.startswith("/") else href
27
+ return None
28
+
29
+
30
+ async def extract_pyramid(context, url: str) -> dict | None:
31
+ """Extract top/heart/base notes from a Basenotes fragrance page."""
32
+ page = await context.new_page()
33
+ await page.goto(url, wait_until="networkidle")
34
+ html = await page.content()
35
+ soup = BeautifulSoup(html, "html.parser")
36
+
37
+ pyramid = {"top": [], "heart": [], "base": [], "description": ""}
38
+
39
+ # Description / main text
40
+ desc = soup.find("meta", attrs={"name": "description"})
41
+ if desc and desc.get("content"):
42
+ pyramid["description"] = desc["content"].strip()
43
+
44
+ # Note pyramid tables / divs
45
+ # Basenotes uses classes like 'notes-top', 'notes-heart', 'notes-base' or table rows
46
+ for section in ["top", "heart", "base"]:
47
+ selectors = [
48
+ f".notes-{section}",
49
+ f".note-{section}",
50
+ f"[class*='{section} note']",
51
+ f"td[class*='{section}']",
52
+ ]
53
+ for sel in selectors:
54
+ elems = soup.select(sel)
55
+ for el in elems:
56
+ notes = [n.strip() for n in re.split(r"[,;]", el.get_text()) if n.strip()]
57
+ pyramid[section].extend(notes)
58
+ if pyramid[section]:
59
+ break
60
+
61
+ # Fallback: look for any note links under a heading
62
+ if not any(pyramid[s] for s in ["top", "heart", "base"]):
63
+ for heading in soup.find_all(["h2", "h3", "strong"]):
64
+ text = heading.get_text().lower()
65
+ if "top" in text or "heart" in text or "base" in text:
66
+ section = "top" if "top" in text else "heart" if "heart" in text else "base"
67
+ sibling = heading.find_next_sibling()
68
+ if sibling:
69
+ notes = [n.strip() for n in re.split(r"[,;]", sibling.get_text()) if n.strip()]
70
+ pyramid[section].extend(notes)
71
+
72
+ return pyramid
73
+
74
+
75
+ async def main():
76
+ input_path = Path("/home/hermes/pino/data/appell_perfume_names.txt")
77
+ output_path = Path("/home/hermes/pino/data/appell_basenotes_pyramids.jsonl")
78
+
79
+ names = []
80
+ for line in input_path.read_text().strip().splitlines():
81
+ if "|" in line:
82
+ name, extra = line.split("|", 1)
83
+ brand = extra.split()[0] if extra else None
84
+ names.append({"name": name.strip(), "brand": brand})
85
+
86
+ async with AsyncCamoufox(headless=True) as fox:
87
+ context = await fox.new_context()
88
+ for item in names:
89
+ name = item["name"]
90
+ brand = item.get("brand")
91
+ print(f"Searching: {name} ({brand or 'no brand'})")
92
+ try:
93
+ url = await search_basenotes(context, name, brand)
94
+ if not url:
95
+ print(f" No Basenotes URL found for {name}")
96
+ continue
97
+ pyramid = await extract_pyramid(context, url)
98
+ if pyramid:
99
+ pyramid["name"] = name
100
+ pyramid["brand"] = brand
101
+ pyramid["url"] = url
102
+ with output_path.open("a", encoding="utf-8") as f:
103
+ f.write(json.dumps(pyramid, ensure_ascii=False) + "\n")
104
+ print(f" Got pyramid for {name}: {pyramid}")
105
+ except Exception as e:
106
+ print(f" Error for {name}: {e}")
107
+ time.sleep(2)
108
+
109
+
110
+ if __name__ == "__main__":
111
+ asyncio.run(main())
src/pino/upload_data.py CHANGED
@@ -40,6 +40,6 @@ def split_and_upload_dataset(jsonl_path: str, repo_id: str) -> None:
40
 
41
  if __name__ == "__main__":
42
  split_and_upload_dataset(
43
- jsonl_path="data/synthetic_dataset_v2.jsonl",
44
  repo_id="mattbitzesty/pino-synthetic-dataset",
45
  )
 
40
 
41
  if __name__ == "__main__":
42
  split_and_upload_dataset(
43
+ jsonl_path="data/synthetic_dataset_v2_text.jsonl",
44
  repo_id="mattbitzesty/pino-synthetic-dataset",
45
  )