From ce3b3aafa2f5d80f6ce19b9113d854cc617a3399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Katja=20Ber=C4=8Di=C4=8D?= Date: Thu, 30 Nov 2023 16:36:18 -0500 Subject: [PATCH] Add Wikipedia items, query to results page --- README.md | 15 ++ web/concepts/templates/index.html | 3 +- web/concepts/templates/results.html | 2 + web/concepts/views.py | 5 +- .../management/commands/import_wikidata.py | 4 +- web/slurper/source_wikidata.py | 190 ++--------------- web/slurper/wd_raw_item.py | 191 ++++++++++++++++++ 7 files changed, 235 insertions(+), 175 deletions(-) create mode 100644 web/slurper/wd_raw_item.py diff --git a/README.md b/README.md index a96355a..0517efd 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,21 @@ To update the database with the new model, run: ./manage.py rebuild_db sudo systemctl start mathswitch +## WD item JSON example + +``` +{ + 'item': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q192276'}, + 'art': {'type': 'uri', 'value': 'https://en.wikipedia.org/wiki/Measure_(mathematics)'}, + 'image': {'type': 'uri', 'value': 'http://commons.wikimedia.org/wiki/Special:FilePath/Measure%20illustration%20%28Vector%29.svg'}, + 'mwID': {'type': 'literal', 'value': 'Measure'}, + 'itemLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'measure'}, + 'itemDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'function assigning numbers to some subsets of a set, which could be seen as a generalization of length, area, volume and integral'}, + 'eomID': {'type': 'literal', 'value': 'measure'}, + 'pwID': {'type': 'literal', 'value': 'Definition:Measure_(Measure_Theory)' +} +``` + ## WD query examples ``` diff --git a/web/concepts/templates/index.html b/web/concepts/templates/index.html index e099b4c..fb5ee60 100644 --- a/web/concepts/templates/index.html +++ b/web/concepts/templates/index.html @@ -13,7 +13,8 @@

Examples: circuit, mathematical group, - Stone duality + Stone duality, + normal

diff --git a/web/concepts/templates/results.html b/web/concepts/templates/results.html index e8c40e1..33589cb 100644 --- a/web/concepts/templates/results.html +++ b/web/concepts/templates/results.html @@ -4,6 +4,8 @@

Search results

+

Query: "{{ query }}"

+