From 8cd227c551f772e142002171e0c928db637ecb08 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 28 Jul 2023 13:21:37 +0200 Subject: use match --- gn3-guile/web/webserver.scm | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'gn3-guile/web') diff --git a/gn3-guile/web/webserver.scm b/gn3-guile/web/webserver.scm index 123abf5..fb0ed38 100755 --- a/gn3-guile/web/webserver.scm +++ b/gn3-guile/web/webserver.scm @@ -156,10 +156,11 @@ SELECT DISTINCT * where { wd:Q158695 wdt:P225 ?o . } limit 10 " (sparql-tsv (wd-sparql-endpoint-url) (string-append " -SELECT DISTINCT * where { +SELECT DISTINCT ?taxon ?ncbi ?descr where { wd:" species " " (wdt-taxon-name) " ?taxon ; wdt:P685 ?ncbi ; schema:description ?descr . + ?species wdt:P685 ?ncbi . FILTER (lang(?descr)='en') } limit 5 @@ -252,15 +253,17 @@ SELECT ?species ?p ?o WHERE { (let ([wd-id (url-parse-id (assoc-ref rec "22-rdf-syntax-ns#isDefinedBy"))]) (if (string=? wd-id "unknown") rec - ; wikidata query: - (receive (names row) (tsv->scm (sparql-wd-species-info wd-id)) - (display wd-id) - (display row) - (let ([ncbi (car (cdr (car row)) )]) - (cons `("wikidata" . ,wd-id) - (cons `("ncbi" . ,ncbi) - (cons `("taxonomy-name" . ,(car (car row))) rec)) - )) + ; wikidata query: + (receive (names row) (tsv->scm (sparql-wd-species-info wd-id)) + (match (pk (car row)) + ((taxonomy-name ncbi descr) + (cons `("wikidata" . ,wd-id) + (cons `("ncbi" . ,ncbi) + (cons `("taxonomy-name" . ,taxonomy-name) + ; (cons `("shortname" . ,shortname) + (cons `("description" . ,descr) + rec))))) + ) ))) ) (get-species) )) -- cgit v1.2.3