fititnt / openstreetmap-data-intent

[workling-draft] See https://docs.google.com/presentation/d/1V3gDPh5uzmIYtuPptFJY1GbfbvnxW_ViWuIsnSr9bhQ/edit?usp=sharing
The Unlicense
0 stars 0 forks source link

MVP of remote fetch for Wikidata information #1

Closed fititnt closed 1 year ago

fititnt commented 1 year ago

Minimal viable product of proof of concept of making remote fetch and enhance the initial drafts of intent.

Maybe the initial attempt could be get labels from Wikidata, but later could be OpenStreetMap taginfo

fititnt commented 1 year ago

very early proof of concept.

Already do some basic local caching (defauting to 23h, most code for logic is initialy from from) but for Wikidata, both output some metadata and (not really optimized, also only for one parameter for now) query.

Similar approach could be done for data items (however, data items from Sophox is different the query, but we could do both Sophox and attempt do to a test with user doing a import into a local SPARQL database, like with https://jena.apache.org/).

input tests/data/example-003.json

{
    "_description": "A hospital facility (not a building) open, not explicitly with fees",
    "osmm": [
        [
            "amenity=hospital"
        ],
        [
            "healthcare=hospital"
        ]
    ],
    "osmm_not": [
        [
            "fee=yes"
        ],
        [
            "opening_hours=24/7 off"
        ],
        [
            "access=no"
        ],
        [
            "access=private"
        ],
        [
            "operator:type=private"
        ]
    ],
    "dataitem": [
        "Q4941",
        "Q19776"
    ],
    "wikidata": [
        "Q16917"
    ]
}

output

input:
  di:
    di:
      - - amenity=hospital
      - - healthcare=hospital
    di_not:
      - - fee=yes
      - - opening_hours=24/7 off
      - - access=no
      - - access=private
      - - operator:type=private
    di_dataitem:
      - Q4941
      - Q19776
    di_wikidata:
      - Q16917
output:
  driver:
    D2:
      healthcare=hospital: https://wiki.openstreetmap.org/wiki/Tag:healthcare%3Dhospital
      amenity=hospital: https://wiki.openstreetmap.org/wiki/Tag:amenity%3Dhospital
    D3:
      healthcare=hospital: https://taginfo.openstreetmap.org/tags/healthcare=hospital
      amenity=hospital: https://taginfo.openstreetmap.org/tags/amenity=hospital
    D9: |-
      (
        nwr["amenity"="hospital"]({{bbox}}) ;
        nwr["healthcare"="hospital"]({{bbox}}) ;
      )->._;
    D10:
      - - alt_name:de=Hospital;Spital;Krankenhaus
        - alt_name:ko=3차 의료기관;상급종합병원
        - description:cs=Nemocnice
        - description:da=Et hospital, der tilbyder medicinsk behandling til indlagte patienter
        - description:de=Eine medizinische Einrichtung, die stationäre medizinische Behandlung anbietet
        - description:el=Νοσοκομείο που παρέχει ενδονοσοκομειακή ιατρική περίθαλψη
        - description:en=A hospital providing in-patient medical treatment
        - description:es=Establecimiento destinado al diagnóstico y tratamiento de enfermos.
        - description:fa=بیمارستان که خدمات پزشکی را به صورت بستری ارائه می‌دهد.
        - description:fr=Établissement où les malades et les blessés sont soignés.
        - description:it=Un ospedale che fornisce cure mediche ai pazienti ricoverati.
        - description:ja=入院治療を提供する病院
        - description:ko=입원 치료를 제공하는 병원
        - description:pl=Szpital zapewniający stacjonarne leczenie medyczne.
        - 'description:pt=Hospital: instituição pública ou privada, de grandes dimensões, que presta cuidados de saúde com pessoal e equipamento especializado, geralmente com permanência prolongada de pacientes e com serviço de urgência.'
        - description:ru=Больница или госпиталь, предоставляющий стационарное медицинское лечение.
        - description:sv=Ett sjukhus som tillhandahåller medicinsk behandling för patienter
        - description:uk=Великий медичний заклад із стаціонарним відділенням.
        - description:zh-hans=可以办理住院手续的医院。社区诊所别用这个。
        - name:en=amenity=hospital
        - name:pt=comodidade=hospital
        - name:sv=facilitet=sjukhus
        - name:uk=Лікарня
        - name:zh-hans=amenity=hospital
        - ref=osmiQ4941
      - - alt_name:de=Krankenhaus;Hospital;Spital
        - description:de=Ein Krankenhaus, das stationäre medizinische Behandlung anbietet
        - description:en=A hospital providing in-patient medical treatment
        - description:es=Un hospital que proporciona tratamiento médico a los pacientes hospitalizados, utilizado además de amenity=hospital.
        - description:pt-br=Um hospital que oferece tratamento médico hospitalar
        - description:pt=Um hospital que oferece tratamento médico hospitalar
        - name:en=healthcare=hospital
        - name:pt=cuidados_de_saúde=hospital
        - ref=osmiQ19776
    D11:
      - - alt_name:ar=مشفى
        - alt_name:ast=clínica;residencia sanitaria;sanatoriu
        - alt_name:be-tarask=шпіталь;клініка
        - alt_name:bho=हास्पिटल;हॉस्पिटल;हस्पताल
        - alt_name:ckb=خەستەخانە;بیمارستان
        - alt_name:cs=špitál
        - alt_name:da=hospital
        - alt_name:dag=dɔɣitɛni;alaafee tuma duu
        - alt_name:de-ch=Krankenhaus
        - alt_name:de=Klinik;Klinikum;Hospital;Spital
        - alt_name:el=κλινική
        - alt_name:en=medical centre;hospitals;hospital facility;medical facility
        - alt_name:es=Nosocomio;Sanatorio;Casa de salud
        - alt_name:eu=erietxe
        - alt_name:fr=clinique;équipement hospitalier
        - alt_name:gsw=Spitol;Klinik
        - alt_name:hr=bolnice
        - alt_name:hsb=klinika;klinikum
        - alt_name:ht=klinik;sant sante;kay doktè
        - alt_name:ig=ụlọ ahuike
        - alt_name:it=nosocomio;sanatorio;policlinico
        - alt_name:ja=ホスピタル;大病院
        - alt_name:ko=클리닉;크리닉
        - alt_name:mhr=эмлымвер;больнице
        - alt_name:ms=rumah sakit
        - alt_name:nb=sjukehus
        - alt_name:nl=hospitaal
        - alt_name:scn=ospitali
        - alt_name:se=buhcciidviessu;buohcciviessu
        - alt_name:sl=špital
        - alt_name:sms=hospital
        - alt_name:ta=ஆதுரச்சாலை;உடல்நலப் பேணகம்
        - alt_name:tl=pagamutan
        - alt_name:tr=sağlık merkezi;tıbbi merkez
        - alt_name:tt=больница
        - alt_name:udm=больница;госпиталь
        - alt_name:uk=шпиталь;клініка
        - alt_name:vi=nhà thương
        - alt_name:zh=医院;綜合醫院
        - description:ak=Baabi a sɛ obi yare a ɔkɔgye ayare
        - description:ar=منشأة للعناية بالصحة
        - description:ast=centru médicu onde s'ingresen enfermos
        - description:az=tibb müəssisəsi növü
        - description:ba=сирлеләрҙе дауалау һәм/йәки стационар төрөндәге медицина ярҙамы күрһәтеүсе медицина учреждениеһының бер төрө
        - description:be-tarask=мэдычная ўстанова
        - description:bho=बेमारी के इलाज के जगह
        - description:bn=প্রধান চিকিৎসা কেন্দ্র
        - description:ca=establiment d'assistència mèdica i sanitària
        - description:ckb=ناوەندی چارەسەری نەخۆشییەکان
        - description:cs=léčebné zařízení
        - description:da=sundhedspleje facilitet (for organisationer, brug sundhed organisation (Q4287745)
        - description:dag=di nyɛla ninsali nim ni chani shɛli polo n ti bori alaafee
        - description:de-ch=medizinische Einrichtung
        - description:de=medizinische Einrichtung
        - description:en-gb=health care facility
        - description:en=health care facility, for individual buildings use hospital building, for organizations use medical organization
        - description:es=instalación sanitaria donde se atiende a los enfermos
        - description:eu=gaixoak artatzeko eraikitako azpiegitura
        - description:fa=محلی برای درمان و نگهداری بیماران
        - description:fi=laitos, jossa potilaat saavat lääketieteellistä hoitoa
        - description:fr=établissement de soins de santé
        - description:ga=institiúd sláinte
        - description:gl=establecemento de asistencia médica e sanitaria
        - description:gsw=e medizineschi Yrichtig
        - description:ha=wurin kula da marasa lafiya
        - description:he=מוסד המספק שירותי רפואה והחלמה
        - description:hr=zdravstvena ustanova
        - description:hsb=mediciniske zarjadnišćo
        - description:ht=espas yo bay swen
        - description:id=institusi perawatan kesehatan
        - description:ig=ụlọ ọrụ nlekọta ahụike, maka ụlọ onye ọ bụla na-eji ụlọ ụlọ ọgwụ, maka òtù dị iche iche na-eji nzukọ ahụike
        - description:it=installazione destinata alla cura e all'assistenza di ammalati e feriti
        - description:ja=病人に医療を提供したり収容する施設
        - description:ka=სამედიცინო დაწესებულება
        - description:ko=질병이나 질환에 대해 의료를 제공하고 환자가 입원하는 시설
        - description:ms=institusi penjagaan kesihatan
        - description:nb=institusjon som yter medisinsk hjelp
        - description:nl=instelling voor intensieve gezondheidszorg
        - description:pl=instytucja medyczna zajmująca się leczeniem w warunkach stacjonarnych
        - description:pt-br=instituição de cuidados de saúde
        - description:pt=instituição de cuidados de saúde
        - description:ru=вид гражданского стационарного медицинского учреждения
        - description:scn=postu unni si cùrunu li malati
        - description:sd=صحت جي خيال لاءِ ادارو
        - description:sk=zdravotnícke zariadenie určené na poskytovanie zdravotnej starostlivosti ľuďom
        - description:sv=sjukvårdsinrättning (för organisationer, använd hälsoorganisation (Q4287745)
        - description:ta=மருத்துவம் சார்ந்தப் பணிகளை அளிக்கக்கூடிய நிறுவம்
        - description:tr=sağlık kurumu
        - description:tt=стационар төрендәге медицина ярдәмен күрсәтү учреждениесе
        - description:tw=Baabi a sɛ obi yare a ɔkɔgye ayarehwɛ
        - description:udm=висисьёслэн эмъюрттэт басьтон интызы
        - description:uk=стаціонарна громадська медична установа для надання медичних, лікувальних і консультаційних послуг з лікування і охорони здоров'я
        - description:vi=là một tổ chức chăm sóc sức khỏe cung cấp điều trị bệnh
        - description:zh-cn=提供医疗服务的机构
        - description:zh-hans=提供医疗服务的机构
        - description:zh-hant=提供醫療服務的機構
        - description:zh-hk=提供醫療服務的機構
        - description:zh-mo=提供醫療服務的機構
        - description:zh-my=提供医疗服务的机构
        - description:zh-sg=提供医疗服务的机构
        - description:zh-tw=提供醫療服務的機構
        - description:zh=提供醫療服務的機構
        - name:aeb-arab=سبيطار
        - name:af=hospitaal
        - name:ak=ayaresabea
        - name:ami=Paisingan
        - name:an=Hespital
        - name:ar=مستشفى
        - name:arc=ܒܝܬ ܟܪܝܗܐ
        - name:arq=سبيطار
        - name:ary=صبيطار
        - name:arz=المستشفى
        - name:ast=hospital
        - name:az=xəstəxana
        - name:azb=مریض‌خانا
        - name:ba=Дауахана
        - name:bcl=Ospital
        - name:be-tarask=лякарня
        - name:be=бальніца
        - name:bg=болница
        - name:bho=अस्पताल
        - name:bn=হাসপাতাল
        - name:bo=སྨན་ཁང་
        - name:br=Ospital
        - name:bs=bolnica
        - name:bxr=Эмнэлгэ
        - name:ca=hospital
        - name:ce=Лазартни
        - name:ceb=Ospital
        - name:chy=Naa'émâhéó'o
        - name:ckb=نەخۆشخانە
        - name:cs=nemocnice
        - name:csb=bòlëca
        - name:cv=Пульница
        - name:cy=ysbyty
        - name:da=sygehus
        - name:dag=ashibiti
        - name:de-ch=Spital
        - name:de=Krankenhaus
        - name:dsb=chórownja
        - name:dtp=lamin pongusapan
        - name:el=νοσοκομείο
        - name:en-ca=hospital
        - name:en-gb=hospital
        - name:en=hospital
        - name:eo=malsanulejo
        - name:es=hospital
        - name:et=haigla
        - name:eu=ospitale
        - name:fa=بیمارستان
        - name:fat=Ayarsabea
        - name:fi=sairaala
        - name:fr=hôpital
        - name:fy=sikehûs
        - name:ga=ospidéal
        - name:gan=病院
        - name:gl=hospital
        - name:gn=Tasyo
        - name:gsw=Chrankehuus
        - name:gu=હોસ્પિટલ
        - name:ha=Asibiti
        - name:hak=Phiang-yèn
        - name:he=בית חולים
        - name:hi=चिकित्सालय
        - name:hr=bolnica
        - name:hsb=chorownja
        - name:ht=Lopital
        - name:hu=kórház
        - name:hy=Հիվանդանոց
        - name:ia=Hospital
        - name:id=rumah sakit
        - name:ie=Hospitale
        - name:ig=Ụlọ ọgwụ
        - name:io=Hospitalo
        - name:is=sjúkrahús
        - name:it=ospedale
        - name:iu=ᐋᓐᓂᐊᕐᕕᒃ
        - name:ja=病院
        - name:jv=Griya sakit
        - name:ka=ჰოსპიტალი
        - name:kab=Ssbiṭar
        - name:kk=Аурухана
        - name:kn=ಆಸ್ಪತ್ರೆ
        - name:ko=병원
        - name:ks=ہَسپَتال
        - name:ku-latn=nexweşxane
        - name:ku=nexweşxane
        - name:ky=Оорукана
        - name:la=Valetudinarium
        - name:lad=Ospital
        - name:lb=Spidol
        - name:lmo=Ospedaa
        - name:ln=Ndáko ya bokɔnɔ
        - name:lo=ໂຮງໜໍ
        - name:lt=ligoninė
        - name:lv=slimnīca
        - name:lzh=醫院
        - name:mg=Hopitaly
        - name:mhr=эмер
        - name:mk=болница
        - name:ml=ആശുപത്രി
        - name:mr=हॉस्पिटल
        - name:ms-arab=هوسڤيتل
        - name:ms=hospital
        - name:mt=sptar
        - name:myv=ормакудо
        - name:mzn=ناخشخنه
        - name:nan=Pēⁿ-īⁿ
        - name:nb=sykehus
        - name:nds=Krankenhuus
        - name:ne=अस्पताल
        - name:nl=ziekenhuis
        - name:nn=sjukehus
        - name:oc=Hospital
        - name:pa=ਹਸਪਤਾਲ
        - name:pl=szpital
        - name:pnb=ہسپتال
        - name:ps=روغتون
        - name:pt-br=hospital
        - name:pt=hospital
        - name:qu=Unquna wasi
        - name:rmf=dukadengo huusa
        - name:rmy=Naslingro'Kher
        - name:ro=spital
        - name:ru=больница
        - name:rup=Spitalu
        - name:scn=spitali
        - name:sco=hospital
        - name:sd=اسپتال
        - name:se=buohcceviessu
        - name:sh=bolnica
        - name:shi=asganfu
        - name:si=ආරෝග්‍යශාලා හෙවත් රෝහල්
        - name:sk=nemocnica
        - name:sl=bolnišnica
        - name:sm=Falema'i
        - name:smj=skihppijviesso
        - name:smn=pyecceiviäsu
        - name:sms=puõccipõrtt
        - name:sn=Chipatara
        - name:so=Isbitaal
        - name:sq=spital
        - name:sr-ec=болница
        - name:sr-el=bolnica
        - name:sr=болница
        - name:sv=sjukhus
        - name:sw=hospitali
        - name:szl=Lazaryt
        - name:ta=மருத்துவமனை
        - name:te=వైద్యశాల
        - name:tg=бемористон
        - name:th=โรงพยาบาล
        - name:tl=ospital
        - name:tn=Sepatela
        - name:tr=hastane
        - name:tt=хастаханә
        - name:tw=Ayaresabea
        - name:udm=эмъяськонни
        - name:uk=лікарня
        - name:ur=ہسپتال
        - name:uz=Kasalxona
        - name:vec=Ospeal
        - name:vi=bệnh viện
        - name:vls=Klinieke
        - name:wa=Ospitå
        - name:war=Baláy-tambalan
        - name:wuu=医院
        - name:xh=Isibhedlele
        - name:yi=שפיטאל
        - name:yo=ilé ìwòsàn
        - name:yue=醫院
        - name:zh-cn=医院
        - name:zh-hans=医院
        - name:zh-hant=醫院
        - name:zh-hk=醫院
        - name:zh-mo=醫院
        - name:zh-my=医院
        - name:zh-sg=医院
        - name:zh-tw=醫院
        - name:zh=醫院
        - ref=wikidataQ16917
    D11.1: |
      SELECT DISTINCT ?item ?itemLabel WHERE {
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
        {
          SELECT DISTINCT ?item WHERE {
            {
              ?item p:P31 ?statement0.
              ?statement0 (ps:P31/(wdt:P279*)) wd:Q16917.
              FILTER(EXISTS { ?statement0 prov:wasDerivedFrom ?reference. })
            }
          }
          # LIMIT 100
        }
      }