App bilingue FR/EN
Browse files- data/dico_en.csv +35 -0
- data/vins_en.csv +76 -0
- index.html +173 -94
data/dico_en.csv
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
terme,definition,exemple
|
| 2 |
+
Tannins,"What dries your mouth, like over-brewed tea. They come from grape skins and seeds, mostly in red wines.","A Cahors has lots of tannins, a Beaujolais very few."
|
| 3 |
+
Dry,"No sugar you can taste. Nothing to do with a wine that ""dries"" your mouth: that's tannins.","A Chablis is dry."
|
| 4 |
+
Off-dry (moelleux),"Slightly sweet, but less than a sweet dessert wine.","A Vouvray moelleux with an apple tart."
|
| 5 |
+
Sweet wine (liquoreux),"Very sweet, almost like honey. Often served with dessert or foie gras.","Sauternes is the star of sweet wines."
|
| 6 |
+
Body,"How heavy the wine feels in your mouth: light like water or thick like whole milk.","A Châteauneuf-du-Pape is full-bodied."
|
| 7 |
+
Acidity,"What makes your mouth water and brings freshness, like lemon.","Muscadet is very acidic, so very fresh."
|
| 8 |
+
Grape variety,"The type of grape, like apple varieties (Golden, Granny Smith…).","Pinot Noir, Chardonnay and Syrah are grape varieties."
|
| 9 |
+
Appellation (AOP),"A protected place name with production rules. The wine is named after the place, not the grape.","Sancerre is an appellation; its grape is Sauvignon."
|
| 10 |
+
Vintage,"The year the grapes were harvested, written on the label.","A 2020 Bordeaux."
|
| 11 |
+
Colour (robe),"The colour of the wine when you look at your glass.","Ruby, golden…"
|
| 12 |
+
Nose,"What the wine smells like before you drink it.","This rosé has a peachy nose."
|
| 13 |
+
Palate,"What you feel when the wine is in your mouth: taste, texture, length.","A round, fruity palate."
|
| 14 |
+
Length,"How long the taste stays after you swallow. Longer often means better quality.","Also measured in ""caudalies"" (1 caudalie = 1 second)."
|
| 15 |
+
Mineral,"A feeling of wet stone, chalk or seashell. Common in fresh whites.","Chablis and Sancerre are very mineral."
|
| 16 |
+
Oaky,"Vanilla, toast or wood aromas that come from ageing in oak barrels.","A Saint-Émilion is often oaky."
|
| 17 |
+
Oak barrel,"The wooden cask where some wines age. It adds vanilla, toastiness and roundness.","Meursault is aged in barrels."
|
| 18 |
+
Brut,"For sparkling wine: very little sugar. The most common style.","Champagne Brut."
|
| 19 |
+
Demi-sec,"For sparkling wine: quite sweet, perfect with dessert.","Demi-sec Champagne with birthday cake."
|
| 20 |
+
Crémant,"A sparkling wine made like Champagne, but elsewhere (Loire, Alsace, Burgundy…) and often cheaper.","Crémant de Loire."
|
| 21 |
+
Pet'Nat,"Pétillant naturel: bubbles from a single fermentation in the bottle. Often cloudy and funky.","A pink Pet'Nat for drinks."
|
| 22 |
+
Natural wine,"Wine made with minimal intervention: organic grapes, few or no added sulphites.","A glug-glug natural Gamay."
|
| 23 |
+
Glug-glug,"A light, fruity wine that is very easy to drink.","A chilled Beaujolais is glug-glug."
|
| 24 |
+
Sulphites,"A preservative (SO2) used in almost every wine to protect it.","""Contains sulphites"" on the label."
|
| 25 |
+
Decanting,"Pouring wine into a carafe so it can breathe and open up.","You decant a young Madiran."
|
| 26 |
+
Corked,"A fault: the wine smells of wet cardboard or a damp cellar. You can send it back at a restaurant.","The waiter lets you taste to check it isn't corked."
|
| 27 |
+
Serving temperature,"Light reds around 14 °C, bold reds around 17 °C, whites and rosés 8–10 °C, bubbles 6–8 °C.","A red that is too warm feels heavy."
|
| 28 |
+
Food pairing,"Choosing a wine that goes well with the dish. Simple rule: light dish, light wine; rich dish, rich wine.","Oysters + Muscadet."
|
| 29 |
+
Sommelier,"The person who recommends wines in a restaurant. Ask them questions, it's their job!","""I'm looking for a light red under €30."""
|
| 30 |
+
Saignée rosé,"Rosé made by bleeding juice off a red-wine tank: often darker and fruitier.","Tavel is very deeply coloured."
|
| 31 |
+
Grand cru,"The most prestigious vineyard level, especially in Burgundy and Alsace. Often expensive.","Chambertin Grand Cru."
|
| 32 |
+
Fruity,"The wine smells and tastes of fruit: strawberry, cherry, peach, citrus…","A very fruity Côtes de Provence rosé."
|
| 33 |
+
Spicy,"Aromas of pepper, clove or liquorice.","Rhône Syrah is peppery."
|
| 34 |
+
Round,"Soft and smooth, with no sharp edges: low acidity and few tannins.","A round Merlot."
|
| 35 |
+
Crisp,"Lots of acidity and freshness: it wakes you up!","A crisp Sancerre."
|
data/vins_en.csv
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
nom,region,aromes,accords,pitch
|
| 2 |
+
Beaujolais-Villages,Beaujolais,strawberry cherry candy raspberry,charcuterie pizza aperitif,The red you drink like fruit juice (for grown-ups).
|
| 3 |
+
Morgon,Beaujolais,black cherry kirsch violet,poultry burger,The Beaujolais that hit the gym.
|
| 4 |
+
Fleurie,Beaujolais,violet peony raspberry,salmon salad quiche,A bunch of flowers in your glass.
|
| 5 |
+
Bourgogne Pinot Noir,Burgundy,morello cherry forest floor,poultry mushrooms,Classy but chill.
|
| 6 |
+
Gevrey-Chambertin,Burgundy,blackcurrant liquorice forest floor leather,beef bourguignon game,To impress your in-laws.
|
| 7 |
+
Mercurey,Burgundy,red berries soft spices,veal cheese,"Burgundy quality, friendly price."
|
| 8 |
+
Côtes du Rhône,Rhône Valley,black fruit pepper garrigue,barbecue pasta bolognese,Your reliable buddy for every night out.
|
| 9 |
+
Crozes-Hermitage,Rhône Valley,blackberry black pepper violet,grilled meat lamb,Peppery Syrah with attitude.
|
| 10 |
+
Châteauneuf-du-Pape,Rhône Valley,candied fruit garrigue liquorice,beef stew game,"Southern sunshine, XXL mode."
|
| 11 |
+
Gigondas,Rhône Valley,black cherry spices cocoa,lamb stew,"Powerful and generous, like a hug."
|
| 12 |
+
Vacqueyras,Rhône Valley,black fruit thyme pepper,rib of beef,Strong but never brutal.
|
| 13 |
+
Bordeaux Supérieur,Bordeaux,blackcurrant plum light oak,steak cheese,The easy Bordeaux that won't scare you.
|
| 14 |
+
Saint-Émilion,Bordeaux,plum vanilla chocolate,duck breast,"Velvet Merlot, château vibes."
|
| 15 |
+
Pauillac,Bordeaux,blackcurrant cedar tobacco,milk-fed lamb,The final boss of reds.
|
| 16 |
+
Médoc,Bordeaux,blackcurrant graphite oak,grilled beef,"Rock-solid, for meat lovers."
|
| 17 |
+
Côtes de Bourg,Bordeaux,red berries liquorice,burger pasta,"Small price, big vibe."
|
| 18 |
+
Chinon,Loire Valley,raspberry bell pepper violet,charcuterie rillettes,The fresh red you serve slightly chilled.
|
| 19 |
+
Saumur-Champigny,Loire Valley,crunchy red berries,poultry savoury tarts,Crunchy like a wild strawberry.
|
| 20 |
+
Bourgueil,Loire Valley,blackcurrant raspberry graphite,pork grilled meat,Cabernet Franc with a kick.
|
| 21 |
+
Cahors,South-West,blackberry plum liquorice,cassoulet duck confit,The black wine. Ultra bold.
|
| 22 |
+
Madiran,South-West,black fruit spices cocoa,duck breast garbure,Rugby-player tannins.
|
| 23 |
+
Marcillac,South-West,blackcurrant pepper raspberry,charcuterie aligot,Aveyron's secret red.
|
| 24 |
+
Corbières,Languedoc,black fruit garrigue bay leaf,barbecue tagine,The South that smells of garrigue.
|
| 25 |
+
Pic Saint-Loup,Languedoc,blackberry thyme pepper,grilled lamb,"Languedoc, premium edition."
|
| 26 |
+
Minervois,Languedoc,cherry spices liquorice,pizza grilled meat,"Sunshine in a bottle, mini price."
|
| 27 |
+
Bandol rouge,Provence,blackberry leather garrigue,beef stew lamb,Mourvèdre with character.
|
| 28 |
+
Alsace Pinot Noir,Alsace,cherry light strawberry,tarte flambée poultry,A red as light as a feather.
|
| 29 |
+
Corse Vin rouge,Corsica,maquis red berries,Corsican charcuterie,The Corsican maquis in your glass.
|
| 30 |
+
Vin nature Gamay,Various,crunchy red berries candy,aperitif tapas,"Natural glug-glug, serve chilled."
|
| 31 |
+
Côtes de Provence rosé,Provence,peach citrus redcurrant,salad grilled meat aperitif,The pale summer rosé for terraces.
|
| 32 |
+
Tavel,Rhône Valley,strawberry spices cherry,Asian food paella,The rosé that thinks it's a red.
|
| 33 |
+
Bandol rosé,Provence,citrus peach spices,bouillabaisse grilled fish,The chic rosé of the Riviera.
|
| 34 |
+
Rosé d'Anjou,Loire Valley,candy strawberry raspberry,aperitif fruit desserts,"Sweet and fruity, the candy rosé."
|
| 35 |
+
Cabernet d'Anjou,Loire Valley,strawberry raspberry barley sugar,spicy food aperitif,"Indulgent rosé, slightly sweet."
|
| 36 |
+
Pays d'Oc rosé,Languedoc,red berries citrus,barbecue picnic,"Small budget, big sunshine."
|
| 37 |
+
Chablis,Burgundy,lemon flint iodine,oysters sushi,"Ultra fresh, like a wave."
|
| 38 |
+
Mâcon-Villages,Burgundy,apple butter white flowers,fish poultry,"Easy, round Chardonnay."
|
| 39 |
+
Meursault,Burgundy,butter hazelnut brioche,lobster creamy poultry,The luxury buttery white.
|
| 40 |
+
Pouilly-Fuissé,Burgundy,citrus toasted almond,fish in sauce,Rich and elegant Chardonnay.
|
| 41 |
+
Sancerre,Loire Valley,grapefruit boxwood flint,goat cheese fish,"Crisp, clean, flawless."
|
| 42 |
+
Pouilly-Fumé,Loire Valley,citrus flint smoke,scallops goat cheese,Smoky Sauvignon with character.
|
| 43 |
+
Muscadet Sèvre-et-Maine,Loire Valley,lemon iodine green apple,oysters mussels,"Seafood's best friend, small price."
|
| 44 |
+
Vouvray sec,Loire Valley,quince apple honey,fish Asian food,Crunchy Chenin with apple.
|
| 45 |
+
Vouvray moelleux,Loire Valley,honey quince apricot,foie gras apple tart,"Sweet but fresh, never cloying."
|
| 46 |
+
Touraine Sauvignon,Loire Valley,citrus redcurrant cut grass,aperitif salad goat cheese,The white that wakes you up.
|
| 47 |
+
Entre-deux-Mers,Bordeaux,citrus white flowers,fish aperitif,Fresh and cheap: approved.
|
| 48 |
+
Sauternes,Bordeaux,honey apricot saffron,foie gras roquefort dessert,The sweet white: honey in a bottle.
|
| 49 |
+
Pessac-Léognan blanc,Bordeaux,citrus oak smoke,fine fish,Grand-style white Bordeaux.
|
| 50 |
+
Alsace Riesling,Alsace,lime light petrol mineral,sauerkraut fish,Sharp as a laser.
|
| 51 |
+
Alsace Gewurztraminer,Alsace,lychee rose spices,Asian food munster,"Lychee and rose, very fragrant."
|
| 52 |
+
Alsace Pinot Gris,Alsace,pear smoke honey,poultry foie gras,"Round, slightly smoky, very soft."
|
| 53 |
+
Viognier Pays d'Oc,Languedoc,apricot peach flowers,chicken curry,"Apricot scent, full of sunshine."
|
| 54 |
+
Condrieu,Rhône Valley,apricot violet peach,fish in cream,Haute-couture Viognier.
|
| 55 |
+
Picpoul de Pinet,Languedoc,lemon iodine flowers,oysters tapas,The white of the southern sea.
|
| 56 |
+
Jurançon sec,South-West,exotic fruit citrus,fish spicy food,Exotic and zesty.
|
| 57 |
+
Jurançon moelleux,South-West,mango pineapple honey,fruit desserts foie gras,"Pineapple and mango, dessert mode."
|
| 58 |
+
Côtes de Gascogne blanc,South-West,grapefruit exotic fruit,aperitif salad,"Tropical white, mini price."
|
| 59 |
+
Vin jaune,Jura,walnut curry spices,comté chicken with morels,Wine UFO: walnut and curry.
|
| 60 |
+
Muscat de Beaumes-de-Venise,Rhône Valley,fresh grape orange flowers,white chocolate desserts,Like biting into sweet grapes.
|
| 61 |
+
Champagne Brut,Champagne,brioche apple citrus,aperitif sushi everything,"Party bubbles, a must."
|
| 62 |
+
Champagne Rosé,Champagne,strawberry raspberry brioche,aperitif red-fruit desserts,Bubbles + pink = perfect combo.
|
| 63 |
+
Champagne Demi-sec,Champagne,white fruit honey brioche,dessert cake,Sweet bubbles for the cake.
|
| 64 |
+
Crémant de Loire,Loire Valley,green apple flowers,aperitif,Champagne bubbles without the price.
|
| 65 |
+
Crémant d'Alsace,Alsace,citrus apple brioche,aperitif tarte flambée,"Fine bubbles, mini budget."
|
| 66 |
+
Crémant de Bourgogne rosé,Burgundy,crunchy red berries,aperitif,Pink bubbles for a toast.
|
| 67 |
+
Clairette de Die,Rhône Valley,muscat grape rose,dessert brunch,"Sweet, light bubbles, super fun."
|
| 68 |
+
Blanquette de Limoux,Languedoc,green apple flowers,aperitif,France's oldest bubbles.
|
| 69 |
+
Pétillant naturel (Pet'Nat),Various,tangy red berries,aperitif picnic,"Natural bubbles, funky and tangy."
|
| 70 |
+
Prosecco,Italy,pear apple flowers,aperitif spritz,Light Italian bubbles.
|
| 71 |
+
Cava,Spain,citrus almond,tapas aperitif,"Spanish bubbles, olé."
|
| 72 |
+
Rioja,Spain,cherry vanilla leather,tapas chorizo,The vanilla Spanish red.
|
| 73 |
+
Chianti,Italy,cherry tomato herbs,pizza pasta,The one that goes with your pizza.
|
| 74 |
+
Malbec argentin,Argentina,blackberry plum violet,burger asado,"Big fruit, super easy."
|
| 75 |
+
Pinot Grigio,Italy,pear lemon,aperitif salad,"Light, neutral, safe."
|
| 76 |
+
Porto Tawny,Portugal,walnut caramel fig,chocolate cheese,Caramel and walnut to end the night.
|
index.html
CHANGED
|
@@ -95,37 +95,108 @@ input[type=range]{width:100%;accent-color:var(--rose)}
|
|
| 95 |
.load{color:var(--prune);font-weight:700;font-size:.9rem}
|
| 96 |
.err{background:var(--blanc);border:2px solid var(--corail);border-radius:12px;padding:.6rem .8rem;font-size:.85rem;color:var(--encre)}
|
| 97 |
textarea{width:100%;box-sizing:border-box;font:inherit;border:2px solid var(--prune);border-radius:12px;padding:.6rem .8rem;background:var(--blanc);color:var(--encre);min-height:140px}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
</style>
|
| 99 |
</head>
|
| 100 |
<body>
|
| 101 |
<div class="page">
|
| 102 |
<div class="phone" id="phone">
|
|
|
|
| 103 |
<div class="logo">GRAPP’</div>
|
| 104 |
-
<p class="tag"
|
| 105 |
<div class="tabs" role="tablist">
|
| 106 |
-
<button id="t0" role="tab" aria-selected="true" data-t="0"
|
| 107 |
-
<button id="t1" role="tab" aria-selected="false" data-t="1"
|
| 108 |
-
<button id="t2" role="tab" aria-selected="false" data-t="2"
|
| 109 |
</div>
|
| 110 |
<div id="ecran"></div>
|
| 111 |
</div>
|
| 112 |
|
| 113 |
<aside class="notes">
|
| 114 |
-
<h1
|
| 115 |
-
<p
|
| 116 |
-
<p class="k"
|
| 117 |
-
<p
|
| 118 |
-
<p class="k"
|
| 119 |
-
<p
|
| 120 |
-
<p class="k"
|
| 121 |
-
<p
|
| 122 |
-
<p style="font-size:.8rem;color:var(--gris)"
|
| 123 |
</aside>
|
| 124 |
</div>
|
| 125 |
-
|
| 126 |
<script src="https://cdn.jsdelivr.net/npm/tesseract.js@5.1.1/dist/tesseract.min.js"></script>
|
| 127 |
<script>
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
function parseCSV(txt){const rows=[];let row=[],f="",q=false;
|
| 130 |
for(let i=0;i<txt.length;i++){const c=txt[i];
|
| 131 |
if(q){if(c=='"'){if(txt[i+1]=='"'){f+='"';i++}else q=false}else f+=c}
|
|
@@ -133,7 +204,12 @@ function parseCSV(txt){const rows=[];let row=[],f="",q=false;
|
|
| 133 |
else if(c=='\n'){row.push(f);rows.push(row);row=[];f=""}else if(c!='\r')f+=c}
|
| 134 |
if(f||row.length){row.push(f);rows.push(row)}
|
| 135 |
const h=rows.shift();return rows.filter(r=>r.length===h.length).map(r=>Object.fromEntries(h.map((k,i)=>[k,isNaN(r[i])||r[i]===""?r[i]:+r[i]])));}
|
| 136 |
-
/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
const VIDES=new Set("vin de du des la le d rouge blanc rose brut sec pays oc aop igp cotes villages".split(" "));
|
| 138 |
function ratio(a,b){if(!a.length&&!b.length)return 1;const m=Array.from({length:a.length+1},()=>new Array(b.length+1).fill(0));
|
| 139 |
for(let i=1;i<=a.length;i++)for(let j=1;j<=b.length;j++)m[i][j]=a[i-1]===b[j-1]?m[i-1][j-1]+1:Math.max(m[i-1][j],m[i][j-1]);
|
|
@@ -148,31 +224,19 @@ function trouverVins(texte){const res={};
|
|
| 148 |
if(best&&best.s>=.99&&!(best.nom in res)){const m=brute.match(/(\d{1,3}(?:[.,]\d{1,2})?)\s*(?:€|eur)/i)||brute.trim().match(/(\d{1,3}(?:[.,]\d{1,2})?)\s*$/);
|
| 149 |
res[best.nom]=m?parseFloat(m[1].replace(",",".")):null}}
|
| 150 |
return res;}
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
const
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
["Verre ou bouteille ?","Tu la joues solo ou on partage ?","format",["Juste un p'tit verre (ou 2)","On prend une bouteille"]],
|
| 157 |
-
["La vie en couleur !","T'es dans quelle team ?","couleur",["Rouge","Blanc","Rosé","Surprends-moi"]],
|
| 158 |
-
["Plus ça pétille…","Un peu de pep's dans ton verre ?","bulles",["J'adore le pétillant","Sans bulles","Peu importe"]],
|
| 159 |
-
["Sucré ou pas ?","Sois honnête, personne ne juge.","sucre",["Sec","Presque sec","Une pointe de douceur","Doux","Team dessert"]],
|
| 160 |
-
["Léger ou costaud ?","Plutôt plume ou plutôt haltère ?","corps",["Tout léger","Léger","Entre les deux","Costaud","Ultra costaud"]],
|
| 161 |
-
["C'est parfait !","Dernière ligne droite : tes goûts et ton budget.","final",null]];
|
| 162 |
let S={tab:0,etape:0,rep:{},carte:null,src:"exemple",fav:[]};
|
| 163 |
try{S.fav=JSON.parse(localStorage.getItem("grapp_fav")||"[]")}catch(e){}
|
| 164 |
const saveFav=()=>{try{localStorage.setItem("grapp_fav",JSON.stringify(S.fav))}catch(e){}};
|
| 165 |
-
const
|
| 166 |
-
const esc=t=>String(t).replace(/[&<>"]/g,c=>({"&":"&","<":"<",">":">",'"':"""}[c]));
|
| 167 |
-
const fiche=v=>`${v.nom} ${v.couleur} ${v.region} ${v.aromes} ${v.accords} ${v.pitch}`;
|
| 168 |
|
| 169 |
function prefs(r){
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
couleur:{Rouge:"rouge",Blanc:"blanc","Rosé":"rose"}[r.couleur]||"peu_importe",
|
| 173 |
-
bulles:{"J'adore le pétillant":"oui","Sans bulles":"non"}[r.bulles]||"peu_importe",
|
| 174 |
-
sucre:Q[4][3].indexOf(r.sucre||"Sec")+1,corps:Q[5][3].indexOf(r.corps||"Entre les deux")+1,
|
| 175 |
-
familles:Object.keys(FAM).filter(k=>(r.familles||[]).includes(FAM[k])),budget:+(r.budget||30),envie:r.envie||""};
|
| 176 |
}
|
| 177 |
const P={sucre:.18,corps:.18,famille:.17,occasion:.12,budget:.15,semantique:.20};
|
| 178 |
function recommander(p,k,carte){
|
|
@@ -181,19 +245,19 @@ function recommander(p,k,carte){
|
|
| 181 |
let sims=df.map(v=>{const f=new Set(norm(fiche(v)).split(" "));let n=0;mots.forEach(w=>{if([...f].some(x=>x.startsWith(w.slice(0,5))))n++});return n});
|
| 182 |
const lo=Math.min(...sims),hi=Math.max(...sims);
|
| 183 |
sims=sims.map(s=>hi>lo?(s-lo)/(hi-lo):1);
|
| 184 |
-
const
|
| 185 |
return df.map((v,i)=>{
|
| 186 |
let prix=p.format==="verre"?v.prix_verre:v.prix_bouteille; if(carte&&carte[v.nom])prix=carte[v.nom];
|
| 187 |
const s={sucre:1-Math.abs(v.sucre-p.sucre)/4,corps:1-Math.abs(v.corps-p.corps)/4,
|
| 188 |
famille:!p.familles.length||p.familles.includes(v.famille)?1:.25,occasion:v.occasion===p.occasion?1:.4,
|
| 189 |
budget:prix<=p.budget?1:Math.max(0,1-(prix-p.budget)/p.budget),semantique:p.envie.trim()?sims[i]:.5};
|
| 190 |
const r=[];
|
| 191 |
-
if(s.sucre>=.75)r.push([
|
| 192 |
-
if(s.corps>=.75)r.push(v.corps<=2?
|
| 193 |
-
if(p.familles.includes(v.famille))r.push(
|
| 194 |
-
if(v.occasion===p.occasion)r.push(
|
| 195 |
-
if(prix<=p.budget)r.push(
|
| 196 |
-
if(p.envie.trim()&&s.semantique>=.7)r.push(
|
| 197 |
return {v,prix,raisons:r,match:Math.round(100*Object.keys(P).reduce((a,c)=>a+P[c]*s[c],0))};
|
| 198 |
}).sort((a,b)=>b.match-a.match).slice(0,k);
|
| 199 |
}
|
|
@@ -202,88 +266,102 @@ function similaires(nom){
|
|
| 202 |
const a=vec(v);
|
| 203 |
return D.vins.filter(x=>x.nom!==nom).map(x=>({x,d:vec(x).reduce((s,t,i)=>s+(t-a[i])**2,0)+(x.famille===v.famille?0:2)+(x.couleur===v.couleur?0:4)})).sort((p,q)=>p.d-q.d).slice(0,3).map(o=>o.x.nom);
|
| 204 |
}
|
|
|
|
|
|
|
| 205 |
const E=document.getElementById("ecran");
|
|
|
|
| 206 |
function carteVin(r){
|
| 207 |
-
const v=r.v,fav=S.fav.includes(v.nom);
|
| 208 |
return `<article class="vin"><header><h3>${EMO[v.couleur]} ${esc(v.nom)}</h3><span class="pct">${r.match}% match</span></header>
|
| 209 |
-
<div class="meta">${esc(v
|
| 210 |
-
<div class="meta"><b>
|
| 211 |
<div class="chips">${r.raisons.map(x=>`<span class="chip">${esc(x)}</span>`).join("")}</div>
|
| 212 |
-
<div class="row"><button class="btn" data-fav="${esc(v.nom)}">${fav?
|
| 213 |
-
<div class="simi">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
}
|
| 215 |
function render(){
|
|
|
|
| 216 |
document.querySelectorAll(".tabs button").forEach(b=>b.setAttribute("aria-selected",+b.dataset.t===S.tab));
|
| 217 |
if(S.tab===1){
|
| 218 |
-
E.innerHTML=`<h2>
|
| 219 |
-
return `<article class="vin"><header><h3>${EMO[v.couleur]} ${esc(n)}</h3><button class="btn" data-fav="${esc(n)}" aria-label="
|
| 220 |
-
<div class="meta">${esc(v
|
| 221 |
-
<div class="simi">
|
| 222 |
-
:`<p class="empty">
|
| 223 |
return;
|
| 224 |
}
|
| 225 |
if(S.tab===2){
|
| 226 |
-
E.innerHTML=`<h2>
|
| 227 |
-
<input type="text" id="dq" placeholder="
|
| 228 |
-
const
|
| 229 |
-
|
|
|
|
| 230 |
const dq=document.getElementById("dq"),dres=document.getElementById("dres");dq.oninput=go;go();return;
|
| 231 |
}
|
| 232 |
const e=S.etape;
|
| 233 |
if(e===0){
|
| 234 |
const src=S.src||"exemple";
|
| 235 |
-
let h=`<h2>
|
| 236 |
-
<div class="src"><button class="opt" data-s="photo" aria-pressed="${src==="photo"}">
|
| 237 |
-
if(src==="photo")h+=`<label class="l" for="ph">
|
| 238 |
-
else if(src==="exemple")h+=`<div class="menu"><img src="${D.img}" alt="
|
| 239 |
-
else h+=`<label class="l" for="tx">
|
| 240 |
-
h+=`<div id="msg"></div><div class="nav"><button class="btn" id="skip">
|
| 241 |
E.innerHTML=h;
|
| 242 |
E.querySelectorAll("[data-s]").forEach(b=>b.onclick=()=>{S.src=b.dataset.s;render()});
|
| 243 |
const ph=document.getElementById("ph");let fichier=null;
|
| 244 |
-
if(ph)ph.onchange=()=>{fichier=ph.files[0];if(fichier)prev.innerHTML=`<div class="menu"><img src="${URL.createObjectURL(fichier)}" alt="
|
| 245 |
const tx=document.getElementById("tx");if(tx)tx.oninput=()=>{S.tx=tx.value};
|
| 246 |
const msg=document.getElementById("msg");
|
| 247 |
-
const fini=c=>{if(Object.keys(c).length){S.carte=c;S.etape=1;render()}else msg.innerHTML=`<p class="err">
|
| 248 |
lire.onclick=async()=>{
|
| 249 |
if(src==="exemple"){fini(trouverVins(D.carteTexte));return}
|
| 250 |
if(src==="texte"){fini(trouverVins(S.tx||""));return}
|
| 251 |
-
if(!fichier){msg.innerHTML=`<p class="err">
|
| 252 |
-
msg.innerHTML=`<p class="load">
|
| 253 |
try{const r=await Tesseract.recognize(fichier,"fra");fini(trouverVins(r.data.text))}
|
| 254 |
-
catch(err){msg.innerHTML=`<p class="err">
|
| 255 |
finally{lire.disabled=false}};
|
| 256 |
skip.onclick=()=>{S.carte=null;S.etape=1;render()};return;
|
| 257 |
}
|
| 258 |
if(e<=7){
|
| 259 |
-
const [
|
| 260 |
-
let h=(S.carte?`<div class="ok">🧾 <b>${Object.keys(S.carte).length}
|
| 261 |
-
`<div class="prog"><span class="sous" style="margin:0">
|
| 262 |
-
if(
|
| 263 |
-
else{const fmt=
|
| 264 |
-
h+=`<label class="l">
|
| 265 |
-
<label class="l" for="bud">
|
| 266 |
-
<label class="l" for="env">
|
| 267 |
-
h+=`<div class="nav"><button class="btn" id="ret">
|
| 268 |
E.innerHTML=h;
|
| 269 |
E.querySelectorAll("[data-o]").forEach(b=>b.onclick=()=>{S.rep[cle]=b.dataset.o;render()});
|
| 270 |
E.querySelectorAll("[data-f]").forEach(b=>b.onclick=()=>{const f=b.dataset.f,L=S.rep.familles;S.rep.familles=L.includes(f)?L.filter(x=>x!==f):[...L,f];render()});
|
| 271 |
const bud=document.getElementById("bud");if(bud){bud.oninput=()=>{S.rep.budget=+bud.value;bv.textContent=bud.value};env.oninput=()=>{S.rep.envie=env.value}}
|
| 272 |
ret.onclick=()=>{S.etape--;render()};
|
| 273 |
-
suiv.onclick=()=>{if(
|
| 274 |
}
|
| 275 |
const r=recommander(prefs(S.rep),3,S.carte);
|
| 276 |
-
E.innerHTML=`<h2>
|
| 277 |
-
(r.length?`<div class="vins">${r.map(carteVin).join("")}</div>`:`<p class="empty">
|
| 278 |
-
`<div class="nav"><button class="btn" id="re">
|
| 279 |
re.onclick=()=>{S.etape=0;S.rep={};S.carte=null;render()};
|
| 280 |
}
|
| 281 |
document.querySelector(".tabs").onclick=ev=>{const b=ev.target.closest("[data-t]");if(b){S.tab=+b.dataset.t;render()}};
|
|
|
|
|
|
|
| 282 |
E.addEventListener("click",ev=>{const b=ev.target.closest("[data-fav]");if(!b)return;const n=b.dataset.fav;S.fav=S.fav.includes(n)?S.fav.filter(x=>x!==n):[...S.fav,n];saveFav();render()});
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
.
|
|
|
|
| 287 |
</script>
|
| 288 |
<!-- Aide à l'installation : iPhone uniquement, dans le navigateur (pas en mode app) -->
|
| 289 |
<style>
|
|
@@ -304,19 +382,20 @@ Promise.all(["data/vins.csv","data/dico.csv","data/carte_exemple.txt"].map(u=>fe
|
|
| 304 |
<div id="iosAide" hidden>
|
| 305 |
<div class="ios-voile" data-ferme></div>
|
| 306 |
<div class="ios-pop" role="dialog" aria-labelledby="iosTitre">
|
| 307 |
-
<button class="ios-x" data-ferme
|
| 308 |
-
<h3 id="iosTitre">
|
| 309 |
-
<p
|
| 310 |
-
<ol>
|
| 311 |
-
|
| 312 |
-
<li>Choisis <b>Sur l'écran d'accueil</b></li>
|
| 313 |
-
<li>Touche <b>Ajouter</b> : c'est fait !</li>
|
| 314 |
-
</ol>
|
| 315 |
-
<button class="btn go" data-ferme>Compris</button>
|
| 316 |
</div>
|
| 317 |
</div>
|
| 318 |
<script>
|
| 319 |
(function(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
var ua=navigator.userAgent||"";
|
| 321 |
var iphone=/iPhone|iPod/.test(ua);
|
| 322 |
var appli=window.navigator.standalone===true||(window.matchMedia&&matchMedia("(display-mode: standalone)").matches);
|
|
|
|
| 95 |
.load{color:var(--prune);font-weight:700;font-size:.9rem}
|
| 96 |
.err{background:var(--blanc);border:2px solid var(--corail);border-radius:12px;padding:.6rem .8rem;font-size:.85rem;color:var(--encre)}
|
| 97 |
textarea{width:100%;box-sizing:border-box;font:inherit;border:2px solid var(--prune);border-radius:12px;padding:.6rem .8rem;background:var(--blanc);color:var(--encre);min-height:140px}
|
| 98 |
+
|
| 99 |
+
/* Sélecteur de langue : discret, en haut à droite du téléphone */
|
| 100 |
+
.lang{position:absolute;top:24px;right:20px;display:flex;align-items:center;gap:2px;font:700 .72rem var(--body);letter-spacing:.06em}
|
| 101 |
+
.lang button{background:none;border:0;padding:.25rem .35rem;color:var(--prune);opacity:.45;cursor:pointer;font:inherit;border-radius:6px}
|
| 102 |
+
.lang button[aria-pressed="true"]{opacity:1;text-decoration:underline;text-underline-offset:3px;text-decoration-thickness:2px}
|
| 103 |
+
.lang span{color:var(--prune);opacity:.35}
|
| 104 |
+
@media (max-width:520px){.lang{top:calc(env(safe-area-inset-top,0px) + 20px);right:max(14px,env(safe-area-inset-right,0px))}}
|
| 105 |
</style>
|
| 106 |
</head>
|
| 107 |
<body>
|
| 108 |
<div class="page">
|
| 109 |
<div class="phone" id="phone">
|
| 110 |
+
<div class="lang" role="group" aria-label="Langue / Language"><button data-lang="fr">FR</button><span>·</span><button data-lang="en">EN</button></div>
|
| 111 |
<div class="logo">GRAPP’</div>
|
| 112 |
+
<p class="tag" data-i="tag"></p>
|
| 113 |
<div class="tabs" role="tablist">
|
| 114 |
+
<button id="t0" role="tab" aria-selected="true" data-t="0" data-i="tab0"></button>
|
| 115 |
+
<button id="t1" role="tab" aria-selected="false" data-t="1" data-i="tab1"></button>
|
| 116 |
+
<button id="t2" role="tab" aria-selected="false" data-t="2" data-i="tab2"></button>
|
| 117 |
</div>
|
| 118 |
<div id="ecran"></div>
|
| 119 |
</div>
|
| 120 |
|
| 121 |
<aside class="notes">
|
| 122 |
+
<h1 data-i="n_h"></h1>
|
| 123 |
+
<p data-i="n_p"></p>
|
| 124 |
+
<p class="k" data-i="n_k1"></p>
|
| 125 |
+
<p data-i="n_p1"></p>
|
| 126 |
+
<p class="k" data-i="n_k2"></p>
|
| 127 |
+
<p data-i="n_p2"></p>
|
| 128 |
+
<p class="k" data-i="n_k3"></p>
|
| 129 |
+
<p data-i="n_p3"></p>
|
| 130 |
+
<p style="font-size:.8rem;color:var(--gris)" data-i="legal"></p>
|
| 131 |
</aside>
|
| 132 |
</div>
|
|
|
|
| 133 |
<script src="https://cdn.jsdelivr.net/npm/tesseract.js@5.1.1/dist/tesseract.min.js"></script>
|
| 134 |
<script>
|
| 135 |
+
/* ---------- Textes FR / EN ---------- */
|
| 136 |
+
const TXT={
|
| 137 |
+
fr:{tag:"L’app pour choisir ton vin sans te prendre la grappe 🍇",tab0:"Tchin Tchin !",tab1:"Mes favoris",tab2:"Dico Vino",
|
| 138 |
+
n_h:"GRAPP, ton sommelier de poche",n_p:"Prends en photo la carte des vins du resto, réponds à 7 questions sans jargon, et GRAPP te sort ton top 3 avec un % de match. Uniquement des vins qui sont sur la carte.",
|
| 139 |
+
n_k1:"Sur ton téléphone",n_p1:"Ouvre ce lien sur ton téléphone, puis <b>Partager → Sur l'écran d'accueil</b> (iPhone) ou <b>⋮ → Ajouter à l'écran d'accueil</b> (Android) : GRAPP s'ouvre alors en plein écran, comme une app.",
|
| 140 |
+
n_k2:"Comment ça marche",n_p2:"Lecture de la photo par OCR (Tesseract.js), reconnaissance des vins tolérante aux fautes, puis recommandation hybride : tes réponses au quiz + ta phrase libre.",
|
| 141 |
+
n_k3:"Version Python",n_p3:"Le code Python (Streamlit) est dans les fichiers du projet. Il tourne aussi dans le navigateur : <a href=\"python.html\">version Streamlit</a>.",
|
| 142 |
+
legal:"À consommer avec modération. L’abus d’alcool est dangereux pour la santé.",
|
| 143 |
+
s1:"Étape 1 · Scanne la carte",s1b:"GRAPP ne te propose que des vins qui sont sur la carte du resto.",photo:"📷 Photo",exemple:"🧾 Exemple",texte:"⌨️ Texte",
|
| 144 |
+
phl:"Prends la carte des vins en photo",txl:"Colle ou tape les vins de la carte",imgalt:"Carte des vins d'exemple : bulles, blancs, rosés, rouges et douceurs avec leurs prix",
|
| 145 |
+
skip:"Pas de carte",lire:"🔍 Lire la carte",none:"Je n'ai reconnu aucun vin de ma base sur cette carte 🤔 Essaie une photo plus nette, ou tape les noms.",
|
| 146 |
+
needphoto:"Ajoute d'abord une photo 😉",ocr:"🔍 L'IA déchiffre la carte… (quelques secondes)",ocrerr:e=>`Lecture impossible (${e}). Tape plutôt les noms des vins.`,
|
| 147 |
+
found:n=>`${n} vins repérés`,question:"Question",back:"⬅ Retour",next:"Suivant ➡",find:"🍇 Trouve mon vin !",
|
| 148 |
+
flav:"Les saveurs qui te font kiffer",budget:f=>`Budget max pour ${f==="verre"?"le verre":"la bouteille"}`,envie:"Ton envie en une phrase",enviePh:"ex : un truc frais avec de la charcuterie",
|
| 149 |
+
res:"Plus qu'à kiffer ✨",top:c=>`Ton top 3${c?" sur la carte du resto":""}`,nores:"Aucun vin ne colle à tes critères. Essaie « Surprends-moi » ou « Peu importe » !",again:"🔄 Recommencer",
|
| 150 |
+
smells:"Ça sent :",with:"Avec :",fav:"❤️ Mes fav",unfav:"💔 Retirer",same:"🔁 Dans le même style :",ifyou:"🔁 Si tu aimes, essaie :",
|
| 151 |
+
favh:"Mes vins pépites",nofav:"Pas encore de favori. Fais le quiz et clique sur ❤️ !",remove:"Retirer",
|
| 152 |
+
dicoh:"Je décrypte le vin !",dicob:"Un mot bizarre sur la carte ? Tape-le.",dicoph:"ex : tanins, brut, carafer…",dicono:"Rien trouvé. Essaie « sec », « robe » ou « crémant ».",
|
| 153 |
+
loading:"🍇 GRAPP se prépare…",loaderr:e=>`Impossible de charger les données (${e}). Recharge la page.`,
|
| 154 |
+
r:{sucre:["Sec, comme tu aimes","Presque sec","Une pointe de douceur","Doux comme demandé","Bien sucré, team gourmand"],light:"Léger et facile",mid:"Équilibré",bold:"Costaud, du caractère",
|
| 155 |
+
prof:"Profil ",occ:"Parfait pour : ",bud:(p,u)=>`Dans ton budget (${p} € ${u==="verre"?"le verre":"la bouteille"})`,envie:"Colle à ton envie du moment"},
|
| 156 |
+
fam:{fruite:"Fruité 🍓",floral:"Floral 🌸",epice:"Épicé 🌶️",boise:"Boisé / vanillé 🪵",mineral:"Frais et minéral 🌊",gourmand:"Gourmand / sucré 🍯"},
|
| 157 |
+
occ:{apero:"Apéro entre potes",repas:"Avec un bon repas",dessert:"Pour le dessert",grande_occasion:"Grosse occasion"},
|
| 158 |
+
Q:[["Alors, on trinque ?","C'est quoi le plan du jour ?"],["Verre ou bouteille ?","Tu la joues solo ou on partage ?"],["La vie en couleur !","T'es dans quelle team ?"],
|
| 159 |
+
["Plus ça pétille…","Un peu de pep's dans ton verre ?"],["Sucré ou pas ?","Sois honnête, personne ne juge."],["Léger ou costaud ?","Plutôt plume ou plutôt haltère ?"],
|
| 160 |
+
["C'est parfait !","Dernière ligne droite : tes goûts et ton budget."]],
|
| 161 |
+
O:{verre:"Juste un p'tit verre (ou 2)",bouteille:"On prend une bouteille",rouge:"Rouge",blanc:"Blanc",rose:"Rosé",peu_importe:"Surprends-moi",
|
| 162 |
+
oui:"J'adore le pétillant",non:"Sans bulles",bpi:"Peu importe",s1:"Sec",s2:"Presque sec",s3:"Une pointe de douceur",s4:"Doux",s5:"Team dessert",
|
| 163 |
+
c1:"Tout léger",c2:"Léger",c3:"Entre les deux",c4:"Costaud",c5:"Ultra costaud"},
|
| 164 |
+
ios:{h:"Mets GRAPP sur ton iPhone 🍇",p:"En 3 secondes, GRAPP s'ouvre en plein écran comme une vraie app.",
|
| 165 |
+
s:['Touche <b>Partager</b> ICO en bas de Safari (ou dans le menu <b>•••</b>)','Choisis <b>Sur l\'écran d\'accueil</b>','Touche <b>Ajouter</b> : c\'est fait !'],ok:"Compris",close:"Fermer"}},
|
| 166 |
+
en:{tag:"The app to pick your wine without the headache 🍇",tab0:"Cheers!",tab1:"My favourites",tab2:"Wine Dico",
|
| 167 |
+
n_h:"GRAPP, your pocket sommelier",n_p:"Snap the restaurant’s wine list, answer 7 jargon-free questions, and GRAPP gives you your top 3 with a match score. Only wines that are actually on the list.",
|
| 168 |
+
n_k1:"On your phone",n_p1:"Open this link on your phone, then <b>Share → Add to Home Screen</b> (iPhone) or <b>⋮ → Add to Home screen</b> (Android): GRAPP then opens full screen, like a real app.",
|
| 169 |
+
n_k2:"How it works",n_p2:"The photo is read by OCR (Tesseract.js), wines are matched despite reading errors, then a hybrid recommendation combines your quiz answers and your free-text craving.",
|
| 170 |
+
n_k3:"Python version",n_p3:"The Python code (Streamlit) is in the project files. It also runs in the browser: <a href=\"python.html\">Streamlit version</a>.",
|
| 171 |
+
legal:"Please drink responsibly. Alcohol abuse is dangerous for your health.",
|
| 172 |
+
s1:"Step 1 · Scan the wine list",s1b:"GRAPP only suggests wines that are on the restaurant’s list.",photo:"📷 Photo",exemple:"🧾 Sample",texte:"⌨️ Text",
|
| 173 |
+
phl:"Take a photo of the wine list",txl:"Paste or type the wines on the list",imgalt:"Sample wine list: sparkling, whites, rosés, reds and sweet wines with prices",
|
| 174 |
+
skip:"No list",lire:"🔍 Read the list",none:"I couldn't recognise any wine from my database on this list 🤔 Try a sharper photo, or type the names.",
|
| 175 |
+
needphoto:"Add a photo first 😉",ocr:"🔍 The AI is reading the list… (a few seconds)",ocrerr:e=>`Couldn't read it (${e}). Type the wine names instead.`,
|
| 176 |
+
found:n=>`${n} wines found`,question:"Question",back:"⬅ Back",next:"Next ➡",find:"🍇 Find my wine!",
|
| 177 |
+
flav:"Flavours you love",budget:f=>`Max budget per ${f==="verre"?"glass":"bottle"}`,envie:"Your craving in one sentence",enviePh:"e.g. something fresh with charcuterie",
|
| 178 |
+
res:"Time to enjoy ✨",top:c=>`Your top 3${c?" from the restaurant’s list":""}`,nores:"No wine matches your criteria. Try “Surprise me” or “Don’t mind”!",again:"🔄 Start over",
|
| 179 |
+
smells:"Smells like:",with:"Goes with:",fav:"❤️ Save",unfav:"💔 Remove",same:"🔁 Same style:",ifyou:"🔁 If you like it, try:",
|
| 180 |
+
favh:"My gem wines",nofav:"No favourites yet. Take the quiz and tap ❤️!",remove:"Remove",
|
| 181 |
+
dicoh:"Wine, decoded!",dicob:"A weird word on the list? Type it.",dicoph:"e.g. tannins, brut, decanting…",dicono:"Nothing found. Try “dry”, “body” or “crémant”.",
|
| 182 |
+
loading:"🍇 GRAPP is getting ready…",loaderr:e=>`Couldn't load the data (${e}). Please reload.`,
|
| 183 |
+
r:{sucre:["Dry, just how you like it","Almost dry","A touch of sweetness","Sweet, as requested","Very sweet, dessert team"],light:"Light and easy",mid:"Balanced",bold:"Bold, full of character",
|
| 184 |
+
prof:"Profile: ",occ:"Perfect for: ",bud:(p,u)=>`Within your budget (€${p} per ${u==="verre"?"glass":"bottle"})`,envie:"Matches your craving"},
|
| 185 |
+
fam:{fruite:"Fruity 🍓",floral:"Floral 🌸",epice:"Spicy 🌶️",boise:"Oaky / vanilla 🪵",mineral:"Fresh & mineral 🌊",gourmand:"Indulgent / sweet 🍯"},
|
| 186 |
+
occ:{apero:"Drinks with friends",repas:"With a good meal",dessert:"With dessert",grande_occasion:"Big occasion"},
|
| 187 |
+
Q:[["So, let’s toast?","What’s the plan today?"],["Glass or bottle?","Going solo or sharing?"],["Life in colour!","Which team are you?"],
|
| 188 |
+
["The more bubbles…","A little fizz in your glass?"],["Sweet or not?","Be honest, nobody’s judging."],["Light or bold?","Feather or dumbbell?"],
|
| 189 |
+
["Perfect!","Last step: your tastes and your budget."]],
|
| 190 |
+
O:{verre:"Just a glass (or two)",bouteille:"Let’s get a bottle",rouge:"Red",blanc:"White",rose:"Rosé",peu_importe:"Surprise me",
|
| 191 |
+
oui:"I love bubbles",non:"No bubbles",bpi:"Don’t mind",s1:"Dry",s2:"Almost dry",s3:"A touch of sweetness",s4:"Sweet",s5:"Dessert team",
|
| 192 |
+
c1:"Very light",c2:"Light",c3:"In between",c4:"Bold",c5:"Very bold"},
|
| 193 |
+
ios:{h:"Put GRAPP on your iPhone 🍇",p:"In 3 seconds, GRAPP opens full screen like a real app.",
|
| 194 |
+
s:['Tap <b>Share</b> ICO at the bottom of Safari (or in the <b>•••</b> menu)','Choose <b>Add to Home Screen</b>','Tap <b>Add</b>: done!'],ok:"Got it",close:"Close"}}};
|
| 195 |
+
let LANG="fr";try{const l=localStorage.getItem("grapp_lang");if(l==="en"||l==="fr")LANG=l}catch(e){}
|
| 196 |
+
const T=()=>TXT[LANG];
|
| 197 |
+
|
| 198 |
+
/* ---------- Données ---------- */
|
| 199 |
+
const D={vins:[],en:{},dico:{fr:[],en:[]},carteTexte:"",img:"assets/carte_exemple.png"};
|
| 200 |
function parseCSV(txt){const rows=[];let row=[],f="",q=false;
|
| 201 |
for(let i=0;i<txt.length;i++){const c=txt[i];
|
| 202 |
if(q){if(c=='"'){if(txt[i+1]=='"'){f+='"';i++}else q=false}else f+=c}
|
|
|
|
| 204 |
else if(c=='\n'){row.push(f);rows.push(row);row=[];f=""}else if(c!='\r')f+=c}
|
| 205 |
if(f||row.length){row.push(f);rows.push(row)}
|
| 206 |
const h=rows.shift();return rows.filter(r=>r.length===h.length).map(r=>Object.fromEntries(h.map((k,i)=>[k,isNaN(r[i])||r[i]===""?r[i]:+r[i]])));}
|
| 207 |
+
/* texte d'un vin dans la langue choisie (le nom de l'appellation ne se traduit pas) */
|
| 208 |
+
const V=(v,k)=>LANG==="en"&&D.en[v.nom]?D.en[v.nom][k]:v[k];
|
| 209 |
+
|
| 210 |
+
/* ---------- Lecture de la carte : même logique que grapp/carte.py ---------- */
|
| 211 |
+
const norm=t=>String(t).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g," ").trim();
|
| 212 |
+
const esc=t=>String(t).replace(/[&<>"]/g,c=>({"&":"&","<":"<",">":">",'"':"""}[c]));
|
| 213 |
const VIDES=new Set("vin de du des la le d rouge blanc rose brut sec pays oc aop igp cotes villages".split(" "));
|
| 214 |
function ratio(a,b){if(!a.length&&!b.length)return 1;const m=Array.from({length:a.length+1},()=>new Array(b.length+1).fill(0));
|
| 215 |
for(let i=1;i<=a.length;i++)for(let j=1;j<=b.length;j++)m[i][j]=a[i-1]===b[j-1]?m[i-1][j-1]+1:Math.max(m[i-1][j],m[i][j-1]);
|
|
|
|
| 224 |
if(best&&best.s>=.99&&!(best.nom in res)){const m=brute.match(/(\d{1,3}(?:[.,]\d{1,2})?)\s*(?:€|eur)/i)||brute.trim().match(/(\d{1,3}(?:[.,]\d{1,2})?)\s*$/);
|
| 225 |
res[best.nom]=m?parseFloat(m[1].replace(",",".")):null}}
|
| 226 |
return res;}
|
| 227 |
+
|
| 228 |
+
/* ---------- Quiz : les réponses sont stockées par identifiant, pas par texte ---------- */
|
| 229 |
+
const QK=[["occasion",["apero","repas","dessert","grande_occasion"]],["format",["verre","bouteille"]],["couleur",["rouge","blanc","rose","peu_importe"]],
|
| 230 |
+
["bulles",["oui","non","bpi"]],["sucre",["s1","s2","s3","s4","s5"]],["corps",["c1","c2","c3","c4","c5"]],["final",null]];
|
| 231 |
+
const lab=(cle,id)=>cle==="occasion"?T().occ[id]:T().O[id];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
let S={tab:0,etape:0,rep:{},carte:null,src:"exemple",fav:[]};
|
| 233 |
try{S.fav=JSON.parse(localStorage.getItem("grapp_fav")||"[]")}catch(e){}
|
| 234 |
const saveFav=()=>{try{localStorage.setItem("grapp_fav",JSON.stringify(S.fav))}catch(e){}};
|
| 235 |
+
const fiche=v=>`${v.nom} ${v.couleur} ${v.region} ${v.aromes} ${v.accords} ${v.pitch} `+(D.en[v.nom]?`${D.en[v.nom].region} ${D.en[v.nom].aromes} ${D.en[v.nom].accords} ${D.en[v.nom].pitch}`:"");
|
|
|
|
|
|
|
| 236 |
|
| 237 |
function prefs(r){
|
| 238 |
+
return {occasion:r.occasion||"apero",format:r.format||"verre",couleur:r.couleur||"rouge",bulles:r.bulles==="bpi"?"peu_importe":(r.bulles||"oui"),
|
| 239 |
+
sucre:+(r.sucre||"s1").slice(1),corps:+(r.corps||"c1").slice(1),familles:r.familles||[],budget:+(r.budget||30),envie:r.envie||""};
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
}
|
| 241 |
const P={sucre:.18,corps:.18,famille:.17,occasion:.12,budget:.15,semantique:.20};
|
| 242 |
function recommander(p,k,carte){
|
|
|
|
| 245 |
let sims=df.map(v=>{const f=new Set(norm(fiche(v)).split(" "));let n=0;mots.forEach(w=>{if([...f].some(x=>x.startsWith(w.slice(0,5))))n++});return n});
|
| 246 |
const lo=Math.min(...sims),hi=Math.max(...sims);
|
| 247 |
sims=sims.map(s=>hi>lo?(s-lo)/(hi-lo):1);
|
| 248 |
+
const R=T().r;
|
| 249 |
return df.map((v,i)=>{
|
| 250 |
let prix=p.format==="verre"?v.prix_verre:v.prix_bouteille; if(carte&&carte[v.nom])prix=carte[v.nom];
|
| 251 |
const s={sucre:1-Math.abs(v.sucre-p.sucre)/4,corps:1-Math.abs(v.corps-p.corps)/4,
|
| 252 |
famille:!p.familles.length||p.familles.includes(v.famille)?1:.25,occasion:v.occasion===p.occasion?1:.4,
|
| 253 |
budget:prix<=p.budget?1:Math.max(0,1-(prix-p.budget)/p.budget),semantique:p.envie.trim()?sims[i]:.5};
|
| 254 |
const r=[];
|
| 255 |
+
if(s.sucre>=.75)r.push(R.sucre[v.sucre-1]);
|
| 256 |
+
if(s.corps>=.75)r.push(v.corps<=2?R.light:v.corps===3?R.mid:R.bold);
|
| 257 |
+
if(p.familles.includes(v.famille))r.push(R.prof+T().fam[v.famille]);
|
| 258 |
+
if(v.occasion===p.occasion)r.push(R.occ+T().occ[v.occasion].toLowerCase());
|
| 259 |
+
if(prix<=p.budget)r.push(R.bud(Math.round(prix),p.format));
|
| 260 |
+
if(p.envie.trim()&&s.semantique>=.7)r.push(R.envie);
|
| 261 |
return {v,prix,raisons:r,match:Math.round(100*Object.keys(P).reduce((a,c)=>a+P[c]*s[c],0))};
|
| 262 |
}).sort((a,b)=>b.match-a.match).slice(0,k);
|
| 263 |
}
|
|
|
|
| 266 |
const a=vec(v);
|
| 267 |
return D.vins.filter(x=>x.nom!==nom).map(x=>({x,d:vec(x).reduce((s,t,i)=>s+(t-a[i])**2,0)+(x.famille===v.famille?0:2)+(x.couleur===v.couleur?0:4)})).sort((p,q)=>p.d-q.d).slice(0,3).map(o=>o.x.nom);
|
| 268 |
}
|
| 269 |
+
|
| 270 |
+
/* ---------- Affichage ---------- */
|
| 271 |
const E=document.getElementById("ecran");
|
| 272 |
+
const EMO={rouge:"🍷",blanc:"🥂",rose:"🌸"};
|
| 273 |
function carteVin(r){
|
| 274 |
+
const v=r.v,fav=S.fav.includes(v.nom),t=T();
|
| 275 |
return `<article class="vin"><header><h3>${EMO[v.couleur]} ${esc(v.nom)}</h3><span class="pct">${r.match}% match</span></header>
|
| 276 |
+
<div class="meta">${esc(V(v,"region"))} · ~${LANG==="en"?"€"+Math.round(r.prix):Math.round(r.prix)+" €"}</div><p class="pitch">${LANG==="en"?"“":"« "}${esc(V(v,"pitch"))}${LANG==="en"?"”":" »"}</p>
|
| 277 |
+
<div class="meta"><b>${t.smells}</b> ${esc(V(v,"aromes"))} · <b>${t.with}</b> ${esc(V(v,"accords"))}</div>
|
| 278 |
<div class="chips">${r.raisons.map(x=>`<span class="chip">${esc(x)}</span>`).join("")}</div>
|
| 279 |
+
<div class="row"><button class="btn" data-fav="${esc(v.nom)}">${fav?t.unfav:t.fav}</button></div>
|
| 280 |
+
<div class="simi">${t.same} ${similaires(v.nom).map(esc).join(", ")}</div></article>`;
|
| 281 |
+
}
|
| 282 |
+
function statique(){
|
| 283 |
+
document.documentElement.lang=LANG;
|
| 284 |
+
document.querySelectorAll("[data-i]").forEach(el=>{el.innerHTML=T()[el.dataset.i]});
|
| 285 |
+
document.querySelectorAll("[data-lang]").forEach(b=>b.setAttribute("aria-pressed",b.dataset.lang===LANG));
|
| 286 |
+
if(window.iosTextes)iosTextes();
|
| 287 |
}
|
| 288 |
function render(){
|
| 289 |
+
const t=T();
|
| 290 |
document.querySelectorAll(".tabs button").forEach(b=>b.setAttribute("aria-selected",+b.dataset.t===S.tab));
|
| 291 |
if(S.tab===1){
|
| 292 |
+
E.innerHTML=`<h2>${t.favh}</h2>`+(S.fav.length?`<div class="vins">${S.fav.map(n=>{const v=D.vins.find(x=>x.nom===n);if(!v)return"";
|
| 293 |
+
return `<article class="vin"><header><h3>${EMO[v.couleur]} ${esc(n)}</h3><button class="btn" data-fav="${esc(n)}" aria-label="${t.remove}">🗑️</button></header>
|
| 294 |
+
<div class="meta">${esc(V(v,"region"))} · ~${LANG==="en"?"€"+v.prix_bouteille:v.prix_bouteille+" €"}</div><p class="pitch">${esc(V(v,"pitch"))}</p>
|
| 295 |
+
<div class="simi">${t.ifyou} ${similaires(n).map(esc).join(", ")}</div></article>`}).join("")}</div>`
|
| 296 |
+
:`<p class="empty">${t.nofav}</p>`);
|
| 297 |
return;
|
| 298 |
}
|
| 299 |
if(S.tab===2){
|
| 300 |
+
E.innerHTML=`<h2>${t.dicoh}</h2><p class="sous">${t.dicob}</p>
|
| 301 |
+
<input type="text" id="dq" placeholder="${esc(t.dicoph)}" value="${esc(S.dq||"")}"><div class="vins" id="dres" style="margin-top:12px"></div>`;
|
| 302 |
+
const dico=D.dico[LANG];
|
| 303 |
+
const go=()=>{S.dq=dq.value;const q=norm(dq.value);const res=q?dico.map(d=>{const tt=norm(d.terme),f=norm(d.definition);let s=tt.includes(q)||q.includes(tt)?10:0;q.split(" ").filter(w=>w.length>3).forEach(w=>{if(f.includes(w.slice(0,5)))s++});return {d,s}}).filter(o=>o.s>0).sort((a,b)=>b.s-a.s).slice(0,3):dico.slice(0,3).map(d=>({d}));
|
| 304 |
+
dres.innerHTML=res.length?res.map(({d})=>`<article class="vin def"><h3>${esc(d.terme)}</h3><p>${esc(d.definition)}</p><p class="pitch">👉 ${esc(d.exemple)}</p></article>`).join(""):`<p class="empty">${t.dicono}</p>`};
|
| 305 |
const dq=document.getElementById("dq"),dres=document.getElementById("dres");dq.oninput=go;go();return;
|
| 306 |
}
|
| 307 |
const e=S.etape;
|
| 308 |
if(e===0){
|
| 309 |
const src=S.src||"exemple";
|
| 310 |
+
let h=`<h2>${t.s1}</h2><p class="sous">${t.s1b}</p>
|
| 311 |
+
<div class="src"><button class="opt" data-s="photo" aria-pressed="${src==="photo"}">${t.photo}</button><button class="opt" data-s="exemple" aria-pressed="${src==="exemple"}">${t.exemple}</button><button class="opt" data-s="texte" aria-pressed="${src==="texte"}">${t.texte}</button></div>`;
|
| 312 |
+
if(src==="photo")h+=`<label class="l" for="ph">${t.phl}</label><input type="file" id="ph" accept="image/*" capture="environment"><div id="prev"></div>`;
|
| 313 |
+
else if(src==="exemple")h+=`<div class="menu"><img src="${D.img}" alt="${esc(t.imgalt)}"></div>`;
|
| 314 |
+
else h+=`<label class="l" for="tx">${t.txl}</label><textarea id="tx" placeholder="Chinon 2020 29 € Sancerre 42 €">${esc(S.tx||"")}</textarea>`;
|
| 315 |
+
h+=`<div id="msg"></div><div class="nav"><button class="btn" id="skip">${t.skip}</button><button class="btn go" id="lire">${t.lire}</button></div>`;
|
| 316 |
E.innerHTML=h;
|
| 317 |
E.querySelectorAll("[data-s]").forEach(b=>b.onclick=()=>{S.src=b.dataset.s;render()});
|
| 318 |
const ph=document.getElementById("ph");let fichier=null;
|
| 319 |
+
if(ph)ph.onchange=()=>{fichier=ph.files[0];if(fichier)prev.innerHTML=`<div class="menu"><img src="${URL.createObjectURL(fichier)}" alt=""></div>`};
|
| 320 |
const tx=document.getElementById("tx");if(tx)tx.oninput=()=>{S.tx=tx.value};
|
| 321 |
const msg=document.getElementById("msg");
|
| 322 |
+
const fini=c=>{if(Object.keys(c).length){S.carte=c;S.etape=1;render()}else msg.innerHTML=`<p class="err">${t.none}</p>`};
|
| 323 |
lire.onclick=async()=>{
|
| 324 |
if(src==="exemple"){fini(trouverVins(D.carteTexte));return}
|
| 325 |
if(src==="texte"){fini(trouverVins(S.tx||""));return}
|
| 326 |
+
if(!fichier){msg.innerHTML=`<p class="err">${t.needphoto}</p>`;return}
|
| 327 |
+
msg.innerHTML=`<p class="load">${t.ocr}</p>`;lire.disabled=true;
|
| 328 |
try{const r=await Tesseract.recognize(fichier,"fra");fini(trouverVins(r.data.text))}
|
| 329 |
+
catch(err){msg.innerHTML=`<p class="err">${esc(t.ocrerr(err.message||err))}</p>`}
|
| 330 |
finally{lire.disabled=false}};
|
| 331 |
skip.onclick=()=>{S.carte=null;S.etape=1;render()};return;
|
| 332 |
}
|
| 333 |
if(e<=7){
|
| 334 |
+
const [cle,ids]=QK[e-1],[titre,sous]=t.Q[e-1];
|
| 335 |
+
let h=(S.carte?`<div class="ok">🧾 <b>${t.found(Object.keys(S.carte).length)}</b>${LANG==="en"?":":" :"} ${Object.keys(S.carte).map(esc).join(", ")}</div>`:"")+
|
| 336 |
+
`<div class="prog"><span class="sous" style="margin:0">${t.question}</span><b>${e}/7</b></div><div class="bar"><i style="width:${e/7*100}%"></i></div><h2>${titre}</h2><p class="sous">${sous}</p>`;
|
| 337 |
+
if(ids){h+=`<div class="opts">${ids.map(id=>`<button class="opt" aria-pressed="${(S.rep[cle]||ids[0])===id}" data-o="${id}">${esc(lab(cle,id))}</button>`).join("")}</div>`}
|
| 338 |
+
else{const fmt=S.rep.format||"verre";S.rep.budget=S.rep.budget||(fmt==="verre"?8:30);S.rep.familles=S.rep.familles||[];
|
| 339 |
+
h+=`<label class="l">${t.flav}</label><div class="chipsel">${Object.keys(t.fam).map(f=>`<button class="opt" aria-pressed="${S.rep.familles.includes(f)}" data-f="${f}">${t.fam[f]}</button>`).join("")}</div>
|
| 340 |
+
<label class="l" for="bud">${t.budget(fmt)}${LANG==="en"?": €":" : "}<span id="bv">${S.rep.budget}</span>${LANG==="en"?"":" €"}</label><input type="range" id="bud" min="3" max="80" value="${S.rep.budget}">
|
| 341 |
+
<label class="l" for="env">${t.envie}</label><input type="text" id="env" value="${esc(S.rep.envie||"")}" placeholder="${esc(t.enviePh)}">`}
|
| 342 |
+
h+=`<div class="nav"><button class="btn" id="ret">${t.back}</button><button class="btn go" id="suiv">${e<7?t.next:t.find}</button></div>`;
|
| 343 |
E.innerHTML=h;
|
| 344 |
E.querySelectorAll("[data-o]").forEach(b=>b.onclick=()=>{S.rep[cle]=b.dataset.o;render()});
|
| 345 |
E.querySelectorAll("[data-f]").forEach(b=>b.onclick=()=>{const f=b.dataset.f,L=S.rep.familles;S.rep.familles=L.includes(f)?L.filter(x=>x!==f):[...L,f];render()});
|
| 346 |
const bud=document.getElementById("bud");if(bud){bud.oninput=()=>{S.rep.budget=+bud.value;bv.textContent=bud.value};env.oninput=()=>{S.rep.envie=env.value}}
|
| 347 |
ret.onclick=()=>{S.etape--;render()};
|
| 348 |
+
suiv.onclick=()=>{if(ids&&!S.rep[cle])S.rep[cle]=ids[0];S.etape++;render()};return;
|
| 349 |
}
|
| 350 |
const r=recommander(prefs(S.rep),3,S.carte);
|
| 351 |
+
E.innerHTML=`<h2>${t.res}</h2><p class="sous">${t.top(!!S.carte)}</p>`+
|
| 352 |
+
(r.length?`<div class="vins">${r.map(carteVin).join("")}</div>`:`<p class="empty">${t.nores}</p>`)+
|
| 353 |
+
`<div class="nav"><button class="btn" id="re">${t.again}</button></div>`;
|
| 354 |
re.onclick=()=>{S.etape=0;S.rep={};S.carte=null;render()};
|
| 355 |
}
|
| 356 |
document.querySelector(".tabs").onclick=ev=>{const b=ev.target.closest("[data-t]");if(b){S.tab=+b.dataset.t;render()}};
|
| 357 |
+
document.querySelector(".lang").onclick=ev=>{const b=ev.target.closest("[data-lang]");if(!b)return;LANG=b.dataset.lang;try{localStorage.setItem("grapp_lang",LANG)}catch(e){}
|
| 358 |
+
S.dq="";statique();if(D.vins.length)render()};
|
| 359 |
E.addEventListener("click",ev=>{const b=ev.target.closest("[data-fav]");if(!b)return;const n=b.dataset.fav;S.fav=S.fav.includes(n)?S.fav.filter(x=>x!==n):[...S.fav,n];saveFav();render()});
|
| 360 |
+
statique();
|
| 361 |
+
E.innerHTML=`<p class="load">${T().loading}</p>`;
|
| 362 |
+
Promise.all(["data/vins.csv","data/vins_en.csv","data/dico.csv","data/dico_en.csv","data/carte_exemple.txt"].map(u=>fetch(u).then(r=>{if(!r.ok)throw new Error(u);return r.text()})))
|
| 363 |
+
.then(([v,ve,d,de,c])=>{D.vins=parseCSV(v);parseCSV(ve).forEach(x=>D.en[x.nom]=x);D.dico.fr=parseCSV(d);D.dico.en=parseCSV(de);D.carteTexte=c;render()})
|
| 364 |
+
.catch(err=>{E.innerHTML=`<p class="err">${esc(T().loaderr(err.message))}</p>`});
|
| 365 |
</script>
|
| 366 |
<!-- Aide à l'installation : iPhone uniquement, dans le navigateur (pas en mode app) -->
|
| 367 |
<style>
|
|
|
|
| 382 |
<div id="iosAide" hidden>
|
| 383 |
<div class="ios-voile" data-ferme></div>
|
| 384 |
<div class="ios-pop" role="dialog" aria-labelledby="iosTitre">
|
| 385 |
+
<button class="ios-x" data-ferme id="iosX">×</button>
|
| 386 |
+
<h3 id="iosTitre"></h3>
|
| 387 |
+
<p id="iosP"></p>
|
| 388 |
+
<ol id="iosOl"></ol>
|
| 389 |
+
<button class="btn go" data-ferme id="iosOk"></button>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
</div>
|
| 391 |
</div>
|
| 392 |
<script>
|
| 393 |
(function(){
|
| 394 |
+
var ICO='<svg class="ios-ico" viewBox="0 0 16 18" aria-hidden="true"><path d="M8 1v10M4.5 4.5 8 1l3.5 3.5M3 8H2v9h12V8h-1" fill="none" stroke="#7D1C4F" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
| 395 |
+
window.iosTextes=function(){var t=TXT[LANG].ios;document.getElementById("iosTitre").textContent=t.h;document.getElementById("iosP").textContent=t.p;
|
| 396 |
+
document.getElementById("iosOl").innerHTML=t.s.map(function(x){return "<li>"+x.replace("ICO",ICO)+"</li>"}).join("");
|
| 397 |
+
document.getElementById("iosOk").textContent=t.ok;document.getElementById("iosX").setAttribute("aria-label",t.close)};
|
| 398 |
+
iosTextes();
|
| 399 |
var ua=navigator.userAgent||"";
|
| 400 |
var iphone=/iPhone|iPod/.test(ua);
|
| 401 |
var appli=window.navigator.standalone===true||(window.matchMedia&&matchMedia("(display-mode: standalone)").matches);
|