An open source, non-profit web search engine
Super Search: mainstream source adapters + intent-driven routing
Daoud Clarkece7545cc165d
diff --git a/devdata/llm_relabel/source_catalog.json b/devdata/llm_relabel/source_catalog.jsonnew file mode 100644index 0000000..58d7b83--- /dev/null+++ b/devdata/llm_relabel/source_catalog.json@@ -0,0 +1,685 @@+{+ "mwmbl": {+ "field": "general",+ "description": "Mwmbl's own crawled web index \u2014 general web pages on any topic."+ },+ "hn": {+ "field": "tech",+ "description": "Hacker News \u2014 tech, startups, programming, and science links/discussion."+ },+ "github": {+ "field": "code",+ "description": "GitHub \u2014 source-code repositories and software projects."+ },+ "stackexchange": {+ "field": "qa",+ "description": "Stack Exchange \u2014 Q&A across programming and many technical topics."+ },+ "arxiv": {+ "field": "academia",+ "description": "arXiv \u2014 academic preprints in physics, CS, maths, biology, etc."+ },+ "pypi": {+ "field": "code",+ "description": "PyPI \u2014 the Python package index."+ },+ "imdb": {+ "field": "entertainment",+ "description": "IMDb \u2014 films, TV shows, actors, and entertainment."+ },+ "nhs": {+ "field": "health",+ "description": "NHS \u2014 authoritative UK consumer health: conditions, symptoms, treatments, medicines and dosages."+ },+ "wikidata_official": {+ "field": "navigational",+ "description": "Official website of a named brand, company, organisation or person (resolved via Wikidata)."+ },+ "homepage": {+ "field": "navigational",+ "description": "Best-guess official homepage for a brand or site name \u2014 for navigational brand queries."+ },+ "guardian": {+ "field": "news",+ "description": "The Guardian \u2014 UK/world news, politics, sport and current events."+ },+ "99percentinvisible_org": {+ "field": "art-design",+ "description": "art-design site (99percentinvisible.org)",+ "domain": "99percentinvisible.org"+ },+ "acoup_blog": {+ "field": "history",+ "description": "history site (acoup.blog)",+ "domain": "acoup.blog"+ },+ "addons_mozilla_org": {+ "field": "tech",+ "description": "Official Mozilla Firefox add-on marketplace with thousands of browser extensions.",+ "domain": "addons.mozilla.org"+ },+ "archive_org": {+ "field": "tech",+ "description": "tech site (archive.org)",+ "domain": "archive.org"+ },+ "asciinema_org": {+ "field": "programming",+ "description": "Terminal session recording platform with thousands of shared command tutorials.",+ "domain": "asciinema.org"+ },+ "bulbapedia_bulbagarden_net": {+ "field": "gaming",+ "description": "gaming site (bulbapedia.bulbagarden.net)",+ "domain": "bulbapedia.bulbagarden.net"+ },+ "ccrma_stanford_edu": {+ "field": "academia",+ "description": "academia site (ccrma.stanford.edu)",+ "domain": "ccrma.stanford.edu"+ },+ "changelog_complete_org": {+ "field": "programming",+ "description": "programming site (changelog.complete.org)",+ "domain": "changelog.complete.org"+ },+ "codeblog_jonskeet_uk": {+ "field": "programming",+ "description": "Jon Skeet's technical blog on C# and programming; medium HN popularity suggests valuable developer content.",+ "domain": "codeblog.jonskeet.uk"+ },+ "community_grafana_com": {+ "field": "programming",+ "description": "Grafana community forum; medium HN popularity with active discussions about monitoring and analytics.",+ "domain": "community.grafana.com"+ },+ "conferences_oreilly_com": {+ "field": "business-finance",+ "description": "business-finance site (conferences.oreilly.com)",+ "domain": "conferences.oreilly.com"+ },+ "creativecommons_org": {+ "field": "business-finance",+ "description": "business-finance site (creativecommons.org)",+ "domain": "creativecommons.org"+ },+ "cyber_harvard_edu": {+ "field": "academia",+ "description": "Harvard Berkman Klein Center for Internet and Society; medium HN popularity with cybersecurity and tech policy content.",+ "domain": "cyber.harvard.edu"+ },+ "db_cs_cmu_edu": {+ "field": "academia",+ "description": "Carnegie Mellon database research group; medium HN popularity with research papers and resources.",+ "domain": "db.cs.cmu.edu"+ },+ "devblogs_microsoft_com": {+ "field": "programming",+ "description": "Official Microsoft developer blog with extensive technical content.",+ "domain": "devblogs.microsoft.com"+ },+ "developer_mozilla_org": {+ "field": "programming",+ "description": "programming site (developer.mozilla.org)",+ "domain": "developer.mozilla.org"+ },+ "diff_wikimedia_org": {+ "field": "tech",+ "description": "Wikimedia diff view and diffing tools documentation.",+ "domain": "diff.wikimedia.org"+ },+ "directory_fsf_org": {+ "field": "programming",+ "description": "Free Software Foundation directory of free and open source software.",+ "domain": "directory.fsf.org"+ },+ "discourse_llvm_org": {+ "field": "programming",+ "description": "LLVM compiler project discussion forum with extensive technical content.",+ "domain": "discourse.llvm.org"+ },+ "discourse_matplotlib_org": {+ "field": "programming",+ "description": "Matplotlib visualization library community forum.",+ "domain": "discourse.matplotlib.org"+ },+ "discourse_mc_stan_org": {+ "field": "science",+ "description": "science site (discourse.mc-stan.org)",+ "domain": "discourse.mc-stan.org"+ },+ "discourse_osgeo_org": {+ "field": "tech",+ "description": "Open Source Geospatial Foundation discussion forum.",+ "domain": "discourse.osgeo.org"+ },+ "discuss_python_org": {+ "field": "programming",+ "description": "Official Python language discussion and development forum.",+ "domain": "discuss.python.org"+ },+ "doc_hal_science": {+ "field": "academia",+ "description": "academia site (doc.hal.science)",+ "domain": "doc.hal.science"+ },+ "docs_djangoproject_com": {+ "field": "programming",+ "description": "Django web framework official comprehensive documentation.",+ "domain": "docs.djangoproject.com"+ },+ "docs_rs": {+ "field": "programming",+ "description": "Docs.rs Rust crate documentation hosting.",+ "domain": "docs.rs"+ },+ "duckduckgo_com": {+ "field": "tech",+ "description": "tech site (duckduckgo.com)",+ "domain": "duckduckgo.com"+ },+ "dynamicecology_wordpress_com": {+ "field": "science",+ "description": "science site (dynamicecology.wordpress.com)",+ "domain": "dynamicecology.wordpress.com"+ },+ "engineering_nyu_edu": {+ "field": "academia",+ "description": "NYU engineering school site with substantial educational and research content.",+ "domain": "engineering.nyu.edu"+ },+ "f_droid_org": {+ "field": "tech",+ "description": "Free and open-source Android app repository with extensive software catalog.",+ "domain": "f-droid.org"+ },+ "forum_freecodecamp_org": {+ "field": "education",+ "description": "education site (forum.freecodecamp.org)",+ "domain": "forum.freecodecamp.org"+ },+ "forum_godotengine_org": {+ "field": "programming",+ "description": "programming site (forum.godotengine.org)",+ "domain": "forum.godotengine.org"+ },+ "forum_obsidian_md": {+ "field": "tech",+ "description": "Note-taking app community forum with knowledge management and productivity content.",+ "domain": "forum.obsidian.md"+ },+ "forums_factorio_com": {+ "field": "gaming",+ "description": "gaming site (forums.factorio.com)",+ "domain": "forums.factorio.com"+ },+ "futilitycloset_com": {+ "field": "history",+ "description": "history site (www.futilitycloset.com)",+ "domain": "www.futilitycloset.com"+ },+ "gamehistory_org": {+ "field": "gaming",+ "description": "Academic resource and reference for video game history research.",+ "domain": "gamehistory.org"+ },+ "genius_com": {+ "field": "music",+ "description": "music site (genius.com)",+ "domain": "genius.com"+ },+ "gis_stackexchange_com": {+ "field": "science",+ "description": "science site (gis.stackexchange.com)",+ "domain": "gis.stackexchange.com"+ },+ "grist_org": {+ "field": "news-politics",+ "description": "Environmental news nonprofit covering climate and sustainability issues.",+ "domain": "grist.org"+ },+ "gutenberg": {+ "field": "books-literature",+ "description": "books-literature site (www.gutenberg.org)",+ "domain": "www.gutenberg.org"+ },+ "hackaday_com": {+ "field": "tech",+ "description": "Electronics and hardware hacking blog with projects and tutorials.",+ "domain": "hackaday.com"+ },+ "hacks_mozilla_org": {+ "field": "programming",+ "description": "programming site (hacks.mozilla.org)",+ "domain": "hacks.mozilla.org"+ },+ "help_archive_org": {+ "field": "other",+ "description": "other site (help.archive.org)",+ "domain": "help.archive.org"+ },+ "home_cern": {+ "field": "science",+ "description": "CERN's official homepage with extensive scientific research and educational content.",+ "domain": "home.cern"+ },+ "hyperallergic_com": {+ "field": "art-design",+ "description": "art-design site (hyperallergic.com)",+ "domain": "hyperallergic.com"+ },+ "indieweb_org": {+ "field": "tech",+ "description": "IndieWeb movement documentation and community standards for personal web ownership.",+ "domain": "indieweb.org"+ },+ "insideclimatenews_org": {+ "field": "news-politics",+ "description": "Climate change journalism publication with investigative reporting.",+ "domain": "insideclimatenews.org"+ },+ "itch_io": {+ "field": "gaming",+ "description": "Indie game distribution platform with thousands of games and creator content.",+ "domain": "itch.io"+ },+ "journals_plos_org": {+ "field": "academia",+ "description": "PLOS open access scientific journal platform with thousands of articles.",+ "domain": "journals.plos.org"+ },+ "lexi_lambda_github_io": {+ "field": "programming",+ "description": "Well-regarded functional programming blog with deep technical articles and tutorials.",+ "domain": "lexi-lambda.github.io"+ },+ "link_springer_com": {+ "field": "academia",+ "description": "Springer's academic publishing platform with vast peer-reviewed journal collection.",+ "domain": "link.springer.com"+ },+ "longreads_com": {+ "field": "news-politics",+ "description": "Long-form journalism aggregator with substantial curated article archive.",+ "domain": "longreads.com"+ },+ "makham_itch_io": {+ "field": "gaming",+ "description": "Game developer portfolio on itch.io with multiple game projects.",+ "domain": "makham.itch.io"+ },+ "markodenic_com": {+ "field": "tech",+ "description": "tech site (markodenic.com)",+ "domain": "markodenic.com"+ },+ "mathbabe_org": {+ "field": "programming",+ "description": "Active blog on mathematics, algorithms, and data science by Cathy O'Neil.",+ "domain": "mathbabe.org"+ },+ "mathenchant_wordpress_com": {+ "field": "science",+ "description": "science site (mathenchant.wordpress.com)",+ "domain": "mathenchant.wordpress.com"+ },+ "minecraft_wiki": {+ "field": "gaming",+ "description": "gaming site (minecraft.wiki)",+ "domain": "minecraft.wiki"+ },+ "musicbrainz_org": {+ "field": "music",+ "description": "music site (musicbrainz.org)",+ "domain": "musicbrainz.org"+ },+ "openstreetmap_org": {+ "field": "maps-places",+ "description": "OpenStreetMap \u2014 places, towns, addresses, and local points of interest (maps/local)."+ },+ "phys_org": {+ "field": "science",+ "description": "Physics and science news portal with research coverage and searchable archives.",+ "domain": "phys.org"+ },+ "pluralistic_net": {+ "field": "news-politics",+ "description": "news-politics site (pluralistic.net)",+ "domain": "pluralistic.net"+ },+ "propublica_org": {+ "field": "news-politics",+ "description": "news-politics site (www.propublica.org)",+ "domain": "www.propublica.org"+ },+ "quantamagazine_org": {+ "field": "science",+ "description": "science site (www.quantamagazine.org)",+ "domain": "www.quantamagazine.org"+ },+ "reactos_org": {+ "field": "tech",+ "description": "ReactOS open-source operating system with extensive documentation.",+ "domain": "reactos.org"+ },+ "reallifemag_com": {+ "field": "news-politics",+ "description": "Real Life magazine with searchable articles on culture and technology.",+ "domain": "reallifemag.com"+ },+ "rosettacode_org": {+ "field": "programming",+ "description": "MediaWiki site with programming solutions across multiple languages, comprehensive searchable resource.",+ "domain": "rosettacode.org"+ },+ "rubygems_org": {+ "field": "programming",+ "description": "Official Ruby package registry with searchable gem documentation and metadata.",+ "domain": "rubygems.org"+ },+ "semiengineering_com": {+ "field": "tech",+ "description": "Semiconductor and electronics industry news with technical depth and searchable archives.",+ "domain": "semiengineering.com"+ },+ "simonwillison_net": {+ "field": "tech",+ "description": "Tech and web development blog from established expert with searchable archive and strong recognition.",+ "domain": "simonwillison.net"+ },+ "slashdot_org": {+ "field": "tech",+ "description": "Technology news and community site with searchable archives and discussion forums.",+ "domain": "slashdot.org"+ },+ "sourceforge_net": {+ "field": "programming",+ "description": "Historical open-source software repository and forge for developer resources.",+ "domain": "sourceforge.net"+ },+ "spectrum_ieee_org": {+ "field": "tech",+ "description": "IEEE technology news and feature publication with substantial peer-reviewed content.",+ "domain": "spectrum.ieee.org"+ },+ "stratechery_com": {+ "field": "business-finance",+ "description": "business-finance site (stratechery.com)",+ "domain": "stratechery.com"+ },+ "techcrunch_com": {+ "field": "business-finance",+ "description": "business-finance site (techcrunch.com)",+ "domain": "techcrunch.com"+ },+ "technicshistory_com": {+ "field": "history",+ "description": "history site (technicshistory.com)",+ "domain": "technicshistory.com"+ },+ "the_president_europarl_europa_eu": {+ "field": "law-government",+ "description": "law-government site (the-president.europarl.europa.eu)",+ "domain": "the-president.europarl.europa.eu"+ },+ "theanarchistlibrary_org": {+ "field": "philosophy",+ "description": "philosophy site (theanarchistlibrary.org)",+ "domain": "theanarchistlibrary.org"+ },+ "thebulletin_org": {+ "field": "news-politics",+ "description": "Bulletin of the Atomic Scientists with analysis on security and science policy.",+ "domain": "thebulletin.org"+ },+ "theconversation_com": {+ "field": "news-politics",+ "description": "Academic experts writing on current issues for general audience.",+ "domain": "theconversation.com"+ },+ "thehill_com": {+ "field": "news-politics",+ "description": "US political and policy news publication with opinion content.",+ "domain": "thehill.com"+ },+ "theintercept_com": {+ "field": "news-politics",+ "description": "news-politics site (theintercept.com)",+ "domain": "theintercept.com"+ },+ "towardsdatascience_com": {+ "field": "programming",+ "description": "Medium publication covering data science, machine learning, and programming tutorials.",+ "domain": "towardsdatascience.com"+ },+ "unherd_com": {+ "field": "news-politics",+ "description": "UK-based opinion and culture publication with commentary and long-form essays.",+ "domain": "unherd.com"+ },+ "usa_streetsblog_org": {+ "field": "news-politics",+ "description": "Streetsblog USA covering transportation, urban planning, and mobility news.",+ "domain": "usa.streetsblog.org"+ },+ "users_rust_lang_org": {+ "field": "programming",+ "description": "Rust language users forum for questions, discussion, and community support.",+ "domain": "users.rust-lang.org"+ },+ "waxy_org": {+ "field": "tech",+ "description": "Technology and culture blog curating internet oddities and discoveries.",+ "domain": "waxy.org"+ },+ "webaim_org": {+ "field": "tech",+ "description": "Web accessibility education and resources for inclusive design.",+ "domain": "webaim.org"+ },+ "webkit_org": {+ "field": "programming",+ "description": "WebKit browser engine official documentation and development resources.",+ "domain": "webkit.org"+ },+ "wiki_archiveteam_org": {+ "field": "tech",+ "description": "Archive Team wiki about web archiving, preservation, and digital archaeology.",+ "domain": "wiki.archiveteam.org"+ },+ "wiki_archlinux_org": {+ "field": "tech",+ "description": "Arch Linux community wiki with extensive Linux system administration guides.",+ "domain": "wiki.archlinux.org"+ },+ "wikidata_org": {+ "field": "other",+ "description": "other site (www.wikidata.org)",+ "domain": "www.wikidata.org"+ },+ "wikisource_org": {+ "field": "books-literature",+ "description": "Large repository of public domain and free-license texts with wiki search functionality.",+ "domain": "wikisource.org"+ },+ "wiktionary": {+ "field": "other",+ "description": "other site (en.wiktionary.org)",+ "domain": "en.wiktionary.org"+ },+ "www2_sqlite_org": {+ "field": "programming",+ "description": "SQLite database documentation and reference with comprehensive guide.",+ "domain": "www2.sqlite.org"+ },+ "www_bellingcat_com": {+ "field": "news-politics",+ "description": "Investigative journalism outlet specializing in open source research with searchable articles.",+ "domain": "www.bellingcat.com"+ },+ "www_centauri_dreams_org": {+ "field": "science",+ "description": "Science and futurism blog focused on space exploration and exoplanet research.",+ "domain": "www.centauri-dreams.org"+ },+ "www_cis_upenn_edu": {+ "field": "programming",+ "description": "University computer science department with courses, research, and technical resources.",+ "domain": "www.cis.upenn.edu"+ },+ "www_cs_princeton_edu": {+ "field": "programming",+ "description": "Elite university computer science department with courses and research.",+ "domain": "www.cs.princeton.edu"+ },+ "www_cs_utexas_edu": {+ "field": "programming",+ "description": "University computer science department with academic and technical resources.",+ "domain": "www.cs.utexas.edu"+ },+ "www_csmonitor_com": {+ "field": "news-politics",+ "description": "International news organization with thoughtful journalism and analysis.",+ "domain": "www.csmonitor.com"+ },+ "www_esa_int": {+ "field": "science",+ "description": "European Space Agency with space exploration and satellite research content.",+ "domain": "www.esa.int"+ },+ "www_etymonline_com": {+ "field": "books-literature",+ "description": "Etymology dictionary tracing word origins and language history.",+ "domain": "www.etymonline.com"+ },+ "www_euronews_com": {+ "field": "news-politics",+ "description": "European news organization with international journalism.",+ "domain": "www.euronews.com"+ },+ "www_gov_uk": {+ "field": "law-government",+ "description": "law-government site (www.gov.uk)",+ "domain": "www.gov.uk"+ },+ "www_hcn_org": {+ "field": "news-politics",+ "description": "High Country News environmental and regional journalism publication.",+ "domain": "www.hcn.org"+ },+ "www_howtogeek_com": {+ "field": "tech",+ "description": "Technology how-to guide blog with extensive tutorials and tech articles.",+ "domain": "www.howtogeek.com"+ },+ "www_johndcook_com": {+ "field": "programming",+ "description": "Technical blog on mathematics, statistics, and software development.",+ "domain": "www.johndcook.com"+ },+ "www_legislation_gov_uk": {+ "field": "law-government",+ "description": "Official UK legislation repository with comprehensive legal text database.",+ "domain": "www.legislation.gov.uk"+ },+ "www_loopinsight_com": {+ "field": "tech",+ "description": "Apple-focused tech blog with regular news and analysis articles.",+ "domain": "www.loopinsight.com"+ },+ "www_lrb_co_uk": {+ "field": "books-literature",+ "description": "London Review of Books literary journal with archives and articles.",+ "domain": "www.lrb.co.uk"+ },+ "www_math_columbia_edu": {+ "field": "academia",+ "description": "Columbia University math department with research and course materials.",+ "domain": "www.math.columbia.edu"+ },+ "www_medievalists_net": {+ "field": "history",+ "description": "history site (www.medievalists.net)",+ "domain": "www.medievalists.net"+ },+ "www_motherjones_com": {+ "field": "news-politics",+ "description": "Investigative news magazine with articles and long-form journalism.",+ "domain": "www.motherjones.com"+ },+ "www_neh_gov": {+ "field": "academia",+ "description": "US National Endowment for Humanities with grant and cultural content.",+ "domain": "www.neh.gov"+ },+ "www_nist_gov": {+ "field": "science",+ "description": "National standards and technology institute with technical standards and resources.",+ "domain": "www.nist.gov"+ },+ "www_nybooks_com": {+ "field": "books-literature",+ "description": "Literary review with book reviews, essays, and cultural criticism.",+ "domain": "www.nybooks.com"+ },+ "www_pewresearch_org": {+ "field": "news-politics",+ "description": "Respected nonpartisan research center with extensive polling and sociological studies.",+ "domain": "www.pewresearch.org"+ },+ "www_popsci_com": {+ "field": "science",+ "description": "Science journalism publication with extensive articles on technology and scientific discovery.",+ "domain": "www.popsci.com"+ },+ "www_poynter_org": {+ "field": "news-politics",+ "description": "Journalism institute with extensive training materials and media criticism articles.",+ "domain": "www.poynter.org"+ },+ "www_sciencenews_org": {+ "field": "science",+ "description": "Science news publication with reporting on research and discovery.",+ "domain": "www.sciencenews.org"+ },+ "www_sigarch_org": {+ "field": "programming",+ "description": "ACM computer architecture group with technical papers and resources.",+ "domain": "www.sigarch.org"+ },+ "www_sigops_org": {+ "field": "programming",+ "description": "ACM operating systems group with systems research papers and resources.",+ "domain": "www.sigops.org"+ },+ "www_space_com": {+ "field": "science",+ "description": "Space and astronomy news publication with extensive content.",+ "domain": "www.space.com"+ },+ "www_springer_com": {+ "field": "academia",+ "description": "Major academic publisher with journals, books, and research content.",+ "domain": "www.springer.com"+ },+ "www_springernature_com": {+ "field": "academia",+ "description": "Springer Nature publishing group with extensive research publications.",+ "domain": "www.springernature.com"+ },+ "www_stanford_edu": {+ "field": "academia",+ "description": "Stanford University's main portal with extensive academic resources.",+ "domain": "www.stanford.edu"+ },+ "www_thestranger_com": {+ "field": "news-politics",+ "description": "Alternative weekly newspaper with news, arts, and cultural coverage.",+ "domain": "www.thestranger.com"+ },+ "www_whitehouse_gov": {+ "field": "law-government",+ "description": "U.S. Executive Branch official portal with government information.",+ "domain": "www.whitehouse.gov"+ }+}\ No newline at end of filediff --git a/mwmbl/settings_common.py b/mwmbl/settings_common.pyindex dedd11e..13be25d 100644--- a/mwmbl/settings_common.py+++ b/mwmbl/settings_common.py@@ -271,6 +271,8 @@ POLAR_PRODUCT_ID_STARTER = os.environ.get("POLAR_PRODUCT_ID_STARTER", "")POLAR_PRODUCT_ID_PRO = os.environ.get("POLAR_PRODUCT_ID_PRO", "")POLAR_SERVER = os.environ.get("POLAR_SERVER", "sandbox")+GUARDIAN_API_KEY = os.environ.get("GUARDIAN_API_KEY", "")+CURRENT_AGREEMENT_VERSIONS = {"TERMS_OF_SERVICE_GUI": "v2026-04-A","TERMS_OF_SERVICE_API": "v2026-04-A",diff --git a/mwmbl/tinysearchengine/super_search_sources/__init__.py b/mwmbl/tinysearchengine/super_search_sources/__init__.pyindex eb877e4..7f1aa24 100644--- a/mwmbl/tinysearchengine/super_search_sources/__init__.py+++ b/mwmbl/tinysearchengine/super_search_sources/__init__.py@@ -7,12 +7,16 @@ orchestrator."""from mwmbl.tinysearchengine.super_search_sources.arxiv import search as search_arxivfrom mwmbl.tinysearchengine.super_search_sources.github import search as search_github+from mwmbl.tinysearchengine.super_search_sources.guardian import search as search_guardianfrom mwmbl.tinysearchengine.super_search_sources.hn import search as search_hn+from mwmbl.tinysearchengine.super_search_sources.homepage import search as search_homepagefrom mwmbl.tinysearchengine.super_search_sources.imdb import search as search_imdbfrom mwmbl.tinysearchengine.super_search_sources.mwmbl_index import search as search_mwmbl+from mwmbl.tinysearchengine.super_search_sources.nhs import search as search_nhsfrom mwmbl.tinysearchengine.super_search_sources.pypi import search as search_pypifrom mwmbl.tinysearchengine.super_search_sources.recipe import load_recipes, make_recipe_sourcefrom mwmbl.tinysearchengine.super_search_sources.stackexchange import search as search_stackexchange+from mwmbl.tinysearchengine.super_search_sources.wikidata import search as search_wikidataSOURCES = {"mwmbl": search_mwmbl,@@ -22,6 +26,10 @@ SOURCES = {"arxiv": search_arxiv,"pypi": search_pypi,"imdb": search_imdb,+ "nhs": search_nhs, # UK consumer-health (conditions, medicines)+ "wikidata_official": search_wikidata, # official website of an entity (P856)+ "homepage": search_homepage, # heuristic brand-homepage guesser+ "guardian": search_guardian, # UK/world news (Content API, needs key)}# Declarative YAML recipes (recipes/*.yaml) are loaded at import time and addeddiff --git a/mwmbl/tinysearchengine/super_search_sources/guardian.py b/mwmbl/tinysearchengine/super_search_sources/guardian.pynew file mode 100644index 0000000..9f3611e--- /dev/null+++ b/mwmbl/tinysearchengine/super_search_sources/guardian.py@@ -0,0 +1,47 @@+"""The Guardian — UK/world news via the Content API.++Needs a (free) API key in ``settings.GUARDIAN_API_KEY`` (env ``GUARDIAN_API_KEY``).+Without a key the source is a no-op (returns []), so it degrades gracefully in+environments where the key isn't configured. Covers the "news" intent that the+tech/academic-skewed catalog otherwise misses.+"""+import logging++import httpx+from django.conf import settings++from mwmbl.crawler.retrieve import extract_from_html_text+from mwmbl.tinysearchengine.indexer import Document++logger = logging.getLogger(__name__)++ENDPOINT = "https://content.guardianapis.com/search"+++async def search(client: httpx.AsyncClient, query: str, limit: int) -> list[Document]:+ api_key = getattr(settings, "GUARDIAN_API_KEY", "")+ if not api_key:+ return []+ try:+ response = await client.get(ENDPOINT, params={+ "q": query,+ "api-key": api_key,+ "show-fields": "trailText",+ "order-by": "relevance",+ "page-size": max(1, min(limit, 10)),+ })+ response.raise_for_status()+ results = response.json().get("response", {}).get("results", [])+ except (httpx.HTTPError, ValueError) as e:+ logger.info("Guardian source failed: %s", e)+ return []++ docs: list[Document] = []+ for item in results:+ title = item.get("webTitle") or ""+ url = item.get("webUrl") or ""+ trail = (item.get("fields") or {}).get("trailText") or ""+ extract = extract_from_html_text(trail) if trail else ""+ if title and url:+ docs.append(Document(title=title, url=url, extract=extract))+ return docsdiff --git a/mwmbl/tinysearchengine/super_search_sources/homepage.py b/mwmbl/tinysearchengine/super_search_sources/homepage.pynew file mode 100644index 0000000..cdb3ebe--- /dev/null+++ b/mwmbl/tinysearchengine/super_search_sources/homepage.py@@ -0,0 +1,53 @@+"""Heuristic brand-homepage guesser for navigational queries.++Many navigational queries are a brand/site name with no dedicated source and no+Wikidata entity ("whitakers keighley", "solvera jewellery"). This slugifies the+query, tries a few common TLDs, and keeps a homepage only if the fetched page's+title actually contains a query term — a cheap relevance guard against random+domain squatters. It complements (does not replace) the general index: it just+surfaces an official homepage candidate the crawl may not have indexed yet.+"""+import logging+import re++import httpx+from bs4 import BeautifulSoup++from mwmbl.tinysearchengine.indexer import Document++logger = logging.getLogger(__name__)++TLDS = (".com", ".co.uk", ".org", ".net")+_UA = "Mozilla/5.0 (compatible; mwmbl-supersearch/1.0; +https://mwmbl.org)"+++async def search(client: httpx.AsyncClient, query: str, limit: int) -> list[Document]:+ slug = re.sub(r"[^a-z0-9]", "", query.lower())+ terms = [t for t in re.split(r"\s+", query.lower().strip()) if len(t) > 1]+ if len(slug) < 3 or not terms:+ return []++ docs: list[Document] = []+ seen: set[str] = set()+ for tld in TLDS:+ if len(docs) >= limit:+ break+ candidate = f"https://{slug}{tld}/"+ try:+ r = await client.get(candidate, follow_redirects=True,+ headers={"User-Agent": _UA})+ except httpx.HTTPError:+ continue+ if r.status_code != 200 or "text/html" not in r.headers.get("content-type", ""):+ continue+ final = str(r.url)+ if final in seen:+ continue+ seen.add(final)+ title = ""+ if (soup := BeautifulSoup(r.text, "html.parser")).title and soup.title.string:+ title = soup.title.string.strip()+ # Keep only if a query term appears in the title (cheap relevance guard).+ if title and any(t in title.lower() for t in terms):+ docs.append(Document(title=title, url=final, extract=""))+ return docsdiff --git a/mwmbl/tinysearchengine/super_search_sources/nhs.py b/mwmbl/tinysearchengine/super_search_sources/nhs.pynew file mode 100644index 0000000..506dc09--- /dev/null+++ b/mwmbl/tinysearchengine/super_search_sources/nhs.py@@ -0,0 +1,44 @@+"""NHS website search (nhs.uk) — authoritative UK consumer-health information.++Covers the health/medical intent (conditions, medicines, symptoms) that the+tech/academic-skewed source catalogue otherwise misses. The NHS search page is+server-rendered; each result is an ``a.app-search-results-item`` whose real+target path is URL-encoded in the click-tracker's ``url`` query parameter.+"""+import logging+from urllib.parse import parse_qs, unquote, urljoin, urlsplit++import httpx+from bs4 import BeautifulSoup++from mwmbl.tinysearchengine.indexer import Document++logger = logging.getLogger(__name__)++ENDPOINT = "https://www.nhs.uk/search/results"+BASE = "https://www.nhs.uk"+_UA = "Mozilla/5.0 (compatible; mwmbl-supersearch/1.0; +https://mwmbl.org)"+++async def search(client: httpx.AsyncClient, query: str, limit: int) -> list[Document]:+ try:+ response = await client.get(ENDPOINT, params={"q": query}, headers={"User-Agent": _UA})+ response.raise_for_status()+ except httpx.HTTPError as e:+ logger.info("NHS source failed: %s", e)+ return []++ soup = BeautifulSoup(response.text, "html.parser")+ docs: list[Document] = []+ for a in soup.select("a.app-search-results-item")[:limit]:+ href = a.get("href") or ""+ title = a.get_text(" ", strip=True)+ # The clean page path is the `url` param of the click-tracking href.+ target = ""+ params = parse_qs(urlsplit(href).query)+ if params.get("url"):+ target = unquote(params["url"][0])+ url = urljoin(BASE, target or href)+ if title and url:+ docs.append(Document(title=title, url=url, extract=""))+ return docsdiff --git a/mwmbl/tinysearchengine/super_search_sources/recipes/openstreetmap_org.yaml b/mwmbl/tinysearchengine/super_search_sources/recipes/openstreetmap_org.yamlnew file mode 100644index 0000000..c9602cd--- /dev/null+++ b/mwmbl/tinysearchengine/super_search_sources/recipes/openstreetmap_org.yaml@@ -0,0 +1,23 @@+name: openstreetmap_org+domain: openstreetmap.org+field: maps-places+request:+ url: https://nominatim.openstreetmap.org/search+ params:+ q: "{query}"+ format: jsonv2+ limit: "{limit}"+ headers:+ User-Agent: "mwmbl-supersearch/1.0 (+https://mwmbl.org)"+response:+ format: json+ results: "" # Nominatim returns a top-level JSON array+ base_url: ""+ fields:+ title: display_name+ extract: name+ url:+ template: "https://www.openstreetmap.org/{osm_type}/{osm_id}"+smoke:+ query: london+ expect_title_contains: Londondiff --git a/mwmbl/tinysearchengine/super_search_sources/wikidata.py b/mwmbl/tinysearchengine/super_search_sources/wikidata.pynew file mode 100644index 0000000..5b265e7--- /dev/null+++ b/mwmbl/tinysearchengine/super_search_sources/wikidata.py@@ -0,0 +1,63 @@+"""Official-website resolver via Wikidata.++Resolves the query to Wikidata entities (``wbsearchentities``) and returns each+entity's official website (property ``P856``). This is the structured, Big-Tech-+independent way to answer navigational/brand queries ("virgin media" ->+https://www.virginmedia.com/) without a per-brand source.+"""+import logging++import httpx++from mwmbl.tinysearchengine.indexer import Document++logger = logging.getLogger(__name__)++API = "https://www.wikidata.org/w/api.php"+OFFICIAL_WEBSITE = "P856"+# Wikimedia's User-Agent policy blocks generic/library UAs; identify ourselves.+_HEADERS = {"User-Agent": "mwmbl-supersearch/1.0 (https://mwmbl.org; [email protected])"}+++async def search(client: httpx.AsyncClient, query: str, limit: int) -> list[Document]:+ n = max(1, min(limit, 5))+ try:+ r = await client.get(API, headers=_HEADERS, params={+ "action": "wbsearchentities", "search": query,+ "language": "en", "format": "json", "limit": n,+ })+ r.raise_for_status()+ hits = r.json().get("search", [])+ except (httpx.HTTPError, ValueError) as e:+ logger.info("Wikidata search failed: %s", e)+ return []++ ids = [h["id"] for h in hits[:n] if h.get("id")]+ if not ids:+ return []++ try:+ r2 = await client.get(API, headers=_HEADERS, params={+ "action": "wbgetentities", "ids": "|".join(ids),+ "props": "claims|labels|descriptions", "languages": "en", "format": "json",+ })+ r2.raise_for_status()+ entities = r2.json().get("entities", {})+ except (httpx.HTTPError, ValueError) as e:+ logger.info("Wikidata entities failed: %s", e)+ return []++ docs: list[Document] = []+ for qid in ids: # preserve search-rank order+ entity = entities.get(qid) or {}+ label = (entity.get("labels", {}).get("en") or {}).get("value", "")+ desc = (entity.get("descriptions", {}).get("en") or {}).get("value", "")+ for claim in entity.get("claims", {}).get(OFFICIAL_WEBSITE, []):+ try:+ url = claim["mainsnak"]["datavalue"]["value"]+ except (KeyError, TypeError):+ continue+ if url:+ docs.append(Document(title=label or url, url=url, extract=desc))+ break # one official site per entity+ return docsdiff --git a/scripts/llm_relabel_pass1.py b/scripts/llm_relabel_pass1.pynew file mode 100644index 0000000..db53c3c--- /dev/null+++ b/scripts/llm_relabel_pass1.py@@ -0,0 +1,123 @@+"""+LLM relabel — Pass 1 prep: build the source catalog Haiku chooses from, and+sample queries for query-analysis (intent + source selection).++This only PREPARES inputs (catalog + sampled queries) and writes the reusable+catalog to devdata/llm_relabel/source_catalog.json. The actual Haiku judging is+driven separately (batched), then checkpointed.++Usage::+ DJANGO_SETTINGS_MODULE=mwmbl.settings_dev DATABASE_URL="postgres://daoud@" \+ uv run python scripts/llm_relabel_pass1.py --num 100 --seed 42+"""+import json+import os+from argparse import ArgumentParser++import django+import numpy as np+import pandas as pd++os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mwmbl.settings_dev")+django.setup()++from mwmbl.rankeval.paths import RANKINGS_DATASET_TRAIN_PATH # noqa: E402+from mwmbl.tinysearchengine.super_search_sources import SOURCES # noqa: E402+from mwmbl.tinysearchengine.super_search_sources.recipe import load_recipes # noqa: E402++CATALOG_PATH = "devdata/llm_relabel/source_catalog.json"++# Hand descriptions for the non-recipe adapters.+ADAPTER_DESC = {+ "mwmbl": ("general", "Mwmbl's own crawled web index — general web pages on any topic."),+ "hn": ("tech", "Hacker News — tech, startups, programming, and science links/discussion."),+ "github": ("code", "GitHub — source-code repositories and software projects."),+ "stackexchange": ("qa", "Stack Exchange — Q&A across programming and many technical topics."),+ "arxiv": ("academia", "arXiv — academic preprints in physics, CS, maths, biology, etc."),+ "pypi": ("code", "PyPI — the Python package index."),+ "imdb": ("entertainment", "IMDb — films, TV shows, actors, and entertainment."),+ "nhs": ("health", "NHS — authoritative UK consumer health: conditions, symptoms, treatments, medicines and dosages."),+ "openstreetmap_org": ("maps-places", "OpenStreetMap — places, towns, addresses, and local points of interest (maps/local)."),+ "wikidata_official": ("navigational", "Official website of a named brand, company, organisation or person (resolved via Wikidata)."),+ "homepage": ("navigational", "Best-guess official homepage for a brand or site name — for navigational brand queries."),+ "guardian": ("news", "The Guardian — UK/world news, politics, sport and current events."),+}++# Post-hoc intent->source augmentation. Haiku classifies intent reliably but+# under-routes the navigational/local/news adapters, so rather than force its+# hand we add the obvious sources deterministically once it tags the intent.+INTENT_SOURCES = {+ "navigational": ["wikidata_official", "homepage"],+ "local": ["openstreetmap_org"],+ "news": ["guardian"],+}+++def augment_sources(intent: str, sources: list[str]) -> list[str]:+ """Layer deterministic intent-driven sources onto Haiku's picks (dedup, keep order)."""+ out = list(dict.fromkeys([*sources, *INTENT_SOURCES.get(intent, [])]))+ if "mwmbl" not in out:+ out.append("mwmbl") # always keep the general index as a baseline+ return out+++def _targets_lookup() -> dict:+ """domain -> reason, from super-search-targets.json (keyed raw and www-stripped)."""+ out = {}+ try:+ domains = json.load(open("super-search-targets.json"))["domains"]+ except Exception:+ return out+ for d in domains:+ name = d.get("name", "")+ reason = d.get("reason") or ""+ field = d.get("field") or ""+ for key in {name, name[4:] if name.startswith("www.") else name, "www." + name}:+ out[key] = {"reason": reason, "field": field}+ return out+++def build_catalog() -> dict:+ targets = _targets_lookup()+ recipes = load_recipes()+ catalog = {}+ for name in SOURCES:+ if name in ADAPTER_DESC:+ field, desc = ADAPTER_DESC[name]+ catalog[name] = {"field": field, "description": desc}+ continue+ rec = recipes.get(name)+ domain = getattr(rec, "domain", name) if rec else name+ field = getattr(rec, "field", "") if rec else ""+ t = targets.get(domain) or {}+ desc = t.get("reason") or f"{field or 'web'} site ({domain})"+ catalog[name] = {"field": t.get("field") or field, "description": desc, "domain": domain}+ return catalog+++def main():+ parser = ArgumentParser()+ parser.add_argument("--num", type=int, default=100)+ parser.add_argument("--seed", type=int, default=42)+ args = parser.parse_args()++ catalog = build_catalog()+ with open(CATALOG_PATH, "w") as f:+ json.dump(catalog, f, indent=2)+ print(f"Wrote {CATALOG_PATH} ({len(catalog)} sources)")++ queries = pd.read_csv(RANKINGS_DATASET_TRAIN_PATH)["query"].unique()+ rng = np.random.default_rng(args.seed)+ sample = sorted(rng.choice(queries, args.num, replace=False).tolist())++ # Catalog text block (for the Haiku prompt)+ print("\n===CATALOG===")+ for name, meta in sorted(catalog.items()):+ print(f"{name} [{meta.get('field','')}]: {meta['description']}")+ print("\n===QUERIES===")+ for q in sample:+ print(q)+++if __name__ == "__main__":+ main()