#!/usr/bin/env python3
import datetime,json,sys
from pathlib import Path
from zoneinfo import ZoneInfo
ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT/'lib'))
from search import Search
s=Search(ROOT);sofa=next(a for a in s.assets if 'room3-rerun2-l-shaped' in a['id']);image=ROOT/sofa['source_photos'][0]
cases=[('black leather sofa',{'query':'black leather sofa'}),('marble coffee table',{'query':'marble coffee table'}),('living-room crop',{'image':str(image)}),('more like sofa',{'like':sofa['id']})]
results={name:s.search(**args,limit=5) for name,args in cases}
out={'when':datetime.datetime.now(ZoneInfo('Europe/Paris')).strftime('%Y-%m-%d %H:%M CET'),'image':str(image),'queries':results}
(ROOT/'W-LIB-search-evidence.json').write_text(json.dumps(out,indent=1))
for name,r in results.items():print(name,[(x['name'],x['score']) for x in r['results']])
