{"database": "scotrail", "path": "/scotrail", "size": 516096, "tables": [{"name": "announcements", "columns": ["File", "Transcription", "Category", "mp3", "Notes", "Timestamp", "NRE_ID"], "primary_keys": ["File"], "count": 2440, "hidden": false, "fts_table": "announcements_fts", "foreign_keys": {"incoming": [], "outgoing": []}, "private": false}, {"name": "announcements_fts", "columns": ["Transcription", "announcements_fts", "rank"], "primary_keys": [], "count": null, "hidden": true, "fts_table": "announcements_fts", "foreign_keys": {"incoming": [], "outgoing": []}, "private": false}, {"name": "announcements_fts_config", "columns": ["k", "v"], "primary_keys": ["k"], "count": 1, "hidden": true, "fts_table": null, "foreign_keys": {"incoming": [], "outgoing": []}, "private": false}, {"name": "announcements_fts_data", "columns": ["id", "block"], "primary_keys": ["id"], "count": 11, "hidden": true, "fts_table": null, "foreign_keys": {"incoming": [], "outgoing": []}, "private": false}, {"name": "announcements_fts_docsize", "columns": ["id", "sz"], "primary_keys": ["id"], "count": 2440, "hidden": true, "fts_table": null, "foreign_keys": {"incoming": [], "outgoing": []}, "private": false}, {"name": "announcements_fts_idx", "columns": ["segid", "term", "pgno"], "primary_keys": ["segid", "term"], "count": 9, "hidden": true, "fts_table": null, "foreign_keys": {"incoming": [], "outgoing": []}, "private": false}], "hidden_count": 5, "views": [], "queries": [{"hide_sql": true, "sql": "with apology as (\n    select Transcription, mp3 from announcements where\n        Category = 'Apology'\n    order by random() limit 1\n),\ntrain_company as (\n    select Transcription, mp3 from announcements where\n        Category = 'Train operating company'\n        and Transcription like '%to%'\n    order by random() limit 1\n),\ndestination as (\n    select Transcription, mp3 from announcements where\n        Category = 'Destination'\n    order by random() limit 1\n),\ncancelled as (\n    select Transcription, mp3 from announcements where\n        Transcription = 'has been cancelled'\n    limit 1\n),\ndue_to as (\n    select Transcription, mp3 from announcements where\n        Transcription = 'due to'\n    limit 1\n),\nreason as (\n    select Transcription, mp3 from announcements where\n        Category = 'Reason'\n    order by random() limit 1\n),\ncombined as (\n  select 1 as sort, * from apology\n  union select 2, * from train_company\n  union select 3, * from destination\n  union select 4, * from cancelled\n  union select 5, * from due_to\n  union select 6, * from reason\n)\nselect * from combined order by sort", "name": "random_apology", "private": false}, {"description_html": "<p>Enter a sequence of terms separated by commas, like this:</p>\n\n<p><code>i am sorry, scotrail, from, bath spa, is delayed, due to, bomb</code></p>\n\n<p>Each term will be treated as a search, and the first, shortest matching clip will be selected.</p>\n\n<p>You can then hit \"Play all\" to hear all the clips as a sequence.</p>", "hide_sql": true, "sql": "with phrases as (\n  select\n    key, value\n  from\n    json_each('[\"' || replace(:terms, ',', '\",\"') || '\"]')\n),\nmatches as (select\n  phrases.key,\n  phrases.value,\n  (\n    select File from announcements\n    where announcements.Transcription like '%' || trim(phrases.value) || '%'\n    order by length(announcements.Transcription)\n    limit 1\n  ) as File\nfrom\n  phrases\n),\nresults as (\n  select key, announcements.Transcription, announcements.mp3\n  from announcements join matches on announcements.File = matches.File\n  order by key\n)\nselect\n  'Combined sentence:' as mp3,\n  group_concat(Transcription, ' ') as Transcription,\n  -1 as key\nfrom results\n  union\nselect\n  mp3, Transcription, key\nfrom results\norder by key", "name": "assemble_sentence", "private": false}], "private": false, "allow_execute_sql": true, "query_ms": 23.357598000075086, "source": "matteason/scotrail-announcements-june-2022", "source_url": "https://github.com/matteason/scotrail-announcements-june-2022"}