diff --git a/README.md b/README.md index 3999218ab..a5758a8ab 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Todos os exemplos no diretório `notebook` são preparados para o ambiente Jupyt # Acionando os Notebooks via Binder * Última versão testada e estável: - [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/santanche/component2learn/v1.1.3) + [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/santanche/component2learn/v1.1.4) * Última versão disponível: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/santanche/component2learn/master) diff --git a/labs/2021/05-services/README.md b/labs/2021/05-services/README.md new file mode 100644 index 000000000..d73ac47c9 --- /dev/null +++ b/labs/2021/05-services/README.md @@ -0,0 +1,14 @@ +# Composição, Serviços e REST +*Lab de Componentização e Reúso de Software 28/08/2021* + +## Bloco 1 + +Entre no [Tarefa 1 do Lab05](https://docs.google.com/presentation/d/1D9bd7SlWm5JjSEdYl8qZkxKEOQXPhBWRbnKeGVau6BU/edit?usp=sharing) e veja as instruções do que deve ser feito na tarefa. Exporte as imagens da tarefa e submeta via GitHub, conforme template disponível em [https://github.com/santanche/component2learn/tree/master/templates/2021/lab05](https://github.com/santanche/component2learn/tree/master/templates/2021/lab05). + +Utilize os modelos disponíveis nos [Diagramas de Referência do Projeto Final](https://docs.google.com/presentation/d/15_LDKDOwjP3UfRa8eKwREHUDkZZuiNRkVl0z_5kApD4/edit?usp=sharing) para elaborar a solução. + +## Bloco 2 + +Através do Jupyter via Binder ou do Jupyter local abra o notebook `labs/2021/05-services/notebook/lab5-base.ipynb` e estude os exemplos lá disponíveis. + +Abra o notebook `labs/2021/05-services/notebook/lab5-tarefas.ipynb` execute as tarefas lá especificadas e submeta e submeta via GitHub, conforme template disponível em [https://github.com/santanche/component2learn/tree/master/templates/2021/lab05](https://github.com/santanche/component2learn/tree/master/templates/2021/lab05). diff --git a/labs/2021/05-services/notebook/geoknowledge.ipynb b/labs/2021/05-services/notebook/geoknowledge.ipynb index b60f1ad42..d64c93bb9 100644 --- a/labs/2021/05-services/notebook/geoknowledge.ipynb +++ b/labs/2021/05-services/notebook/geoknowledge.ipynb @@ -37,7 +37,7 @@ "text": [ "[\n", " {\n", - " \"place_id\": 117591275,\n", + " \"place_id\": 117197145,\n", " \"licence\": \"Data \\u00a9 OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright\",\n", " \"osm_type\": \"way\",\n", " \"osm_id\": 118482151,\n", @@ -183,6 +183,7 @@ ], "source": [ "url_template = \"https://api.openstreetmap.org/api/0.6/{element_type}/{id}.{format}\"\n", + "\n", "element_type = \"way\" # types: node, way, or relation\n", "id = str(museum_ref[0][\"osm_id\"])\n", "format = \"json\"\n", diff --git a/labs/2021/05-services/notebook/lab5-base.ipynb b/labs/2021/05-services/notebook/lab5-base.ipynb new file mode 100644 index 000000000..511cc977f --- /dev/null +++ b/labs/2021/05-services/notebook/lab5-base.ipynb @@ -0,0 +1,1090 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Acessando a DBPedia\n", + "\n", + "Considere a página na Wikipedia do livro [The Tin Drum](https://en.wikipedia.org/wiki/The_Tin_Drum).\n", + "\n", + "Há um nó equivalente na DBPedia em [The Tin Drum](http://dbpedia.org/page/The_Tin_Drum).\n", + "\n", + "## Carregando um nó da DBPedia\n", + "\n", + "A partir do que aprendemos na aula sobre APIs, é possível carregar o conteúdo em JSON desse nó da seguinte maneira:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import io\n", + "import requests\n", + "import json" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"d\": {\n", + " \"results\": [\n", + " {\n", + " \"__metadata\": {\n", + " \"uri\": \"http://dbpedia.org/resource/The_Tin_Drum\"\n", + " },\n", + " \"http://www.w3.org/2000/01/rdf-schema#label\": \"Blaszany b\\u0119benek\",\n", + " \"http://www.w3.org/2002/07/owl#sameAs\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"https://global.dbpedia.org/id/54HrW\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/wikiPageWikiLink\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Amanda_Palmer\"\n", + " }\n", + " },\n", + " \"http://www.w3.org/2000/01/rdf-schema#comment\": \"\\u300e\\u30d6\\u30ea\\u30ad\\u306e\\u592a\\u9f13\\u300f\\uff08\\u30d6\\u30ea\\u30ad\\u306e\\u305f\\u3044\\u3053\\u3001Die Blechtrommel\\uff09\\u306f\\u3001\\u30c9\\u30a4\\u30c4\\u306e\\u4f5c\\u5bb6\\u30ae\\u30e5\\u30f3\\u30bf\\u30fc\\u30fb\\u30b0\\u30e9\\u30b9\\u304c1959\\u5e74\\u306b\\u767a\\u8868\\u3057\\u305f\\u51e6\\u5973\\u4f5c\\u3067\\u3042\\u308a\\u9577\\u7bc7\\u5c0f\\u8aac\\u3067\\u3042\\u308b\\u3002\\u300e\\u732b\\u3068\\u9f20\\u300f\\uff081961\\u5e74\\uff09\\u3001\\u300e\\u72ac\\u306e\\u5e74\\u300f\\uff081963\\u5e74\\uff09\\u3068\\u7d9a\\u304f\\u3001\\u3044\\u308f\\u3086\\u308b\\u300c\\u30c0\\u30f3\\u30c4\\u30a3\\u30d2\\u4e09\\u90e8\\u4f5c\\u300d\\u306e\\u6700\\u521d\\u3092\\u98fe\\u308b\\u4f5c\\u54c1\\u3067\\u3042\\u308a\\u3001\\u7b2c\\u4e8c\\u6b21\\u4e16\\u754c\\u5927\\u6226\\u5f8c\\u306e\\u30c9\\u30a4\\u30c4\\u6587\\u5b66\\u306b\\u304a\\u3051\\u308b\\u6700\\u3082\\u91cd\\u8981\\u306a\\u4f5c\\u54c1\\u306e\\u4e00\\u3064\\u306b\\u6570\\u3048\\u3089\\u308c\\u308b\\u30021979\\u5e74\\u306b\\u30d5\\u30a9\\u30eb\\u30ab\\u30fc\\u30fb\\u30b7\\u30e5\\u30ec\\u30f3\\u30c9\\u30eb\\u30d5\\u306b\\u3088\\u3063\\u3066\\u6620\\u753b\\u5316\\u3055\\u308c\\u305f\\u3002\",\n", + " \"http://dbpedia.org/ontology/abstract\": \"Blecktrumman (originaltitel: Die Blechtrommel) \\u00e4r en roman fr\\u00e5n 1959 av G\\u00fcnter Grass. Denna artikel relaterad till sk\\u00f6nlitteratur av en tysk f\\u00f6rfattare saknar v\\u00e4sentlig information. Du kan hj\\u00e4lpa till genom att l\\u00e4gga till den.\",\n", + " \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/class/yago/Disagreement107180787\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/translator\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Breon_Mitchell\"\n", + " }\n", + " },\n", + " \"http://purl.org/dc/elements/1.1/publisher\": \"Hermann Luchterhand Verlag\",\n", + " \"http://dbpedia.org/ontology/numberOfPages\": \"576\",\n", + " \"http://dbpedia.org/ontology/oclc\": \"3618781\",\n", + " \"http://dbpedia.org/property/wikiPageUsesTemplate\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Template:Infobox_book\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/genre\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Magic_realism\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/wikiPageExternalLink\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://www.dieterwunderlich.de/Grass_blechtrommel.htm\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/releaseDate\": \"1959\",\n", + " \"http://dbpedia.org/ontology/wikiPageID\": \"642383\",\n", + " \"http://dbpedia.org/property/dewey\": \"833.914\",\n", + " \"http://dbpedia.org/property/country\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/West_Germany\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/subsequentWork\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Cat_and_Mouse_(novella)\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/series\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Danzig_Trilogy\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/coverArtist\": \"G\\u00fcnter Grass\",\n", + " \"http://dbpedia.org/property/publisher\": \"Hermann Luchterhand Verlag\",\n", + " \"http://dbpedia.org/property/oclc\": \"3618781\",\n", + " \"http://xmlns.com/foaf/0.1/name\": \"Die Blechtrommel\",\n", + " \"http://xmlns.com/foaf/0.1/isPrimaryTopicOf\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://en.wikipedia.org/wiki/The_Tin_Drum\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/titleOrig\": \"Die Blechtrommel\",\n", + " \"http://dbpedia.org/property/caption\": \"Cover of the first German edition\",\n", + " \"http://purl.org/dc/terms/subject\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Category:Novels_about_Nazis\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/name\": \"The Tin Drum\",\n", + " \"http://purl.org/linguistics/gold/hypernym\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Novel\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/wikiPageLength\": \"15013\",\n", + " \"http://dbpedia.org/ontology/dcc\": \"833.914\",\n", + " \"http://www.w3.org/ns/prov#wasDerivedFrom\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://en.wikipedia.org/wiki/The_Tin_Drum?oldid=1012559301&ns=0\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/coverArtist\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/G\\u00fcnter_Grass\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/language\": \"German\",\n", + " \"http://dbpedia.org/property/author\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/G\\u00fcnter_Grass\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/translator\": \"Ralph Manheim, Breon Mitchell\",\n", + " \"http://dbpedia.org/ontology/wikiPageRevisionID\": \"1012559301\",\n", + " \"http://dbpedia.org/ontology/series\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Danzig_Trilogy\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/author\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/G\\u00fcnter_Grass\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/followedBy\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Cat_and_Mouse_(novella)\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/pages\": \"576\",\n", + " \"http://dbpedia.org/ontology/country\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/West_Germany\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/englishReleaseDate\": \"1961\",\n", + " \"http://dbpedia.org/ontology/literaryGenre\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Magic_realism\"\n", + " }\n", + " }\n", + " }\n", + " ],\n", + " \"__count\": \"1\"\n", + " }\n", + "}\n" + ] + } + ], + "source": [ + "url_drum = \"http://dbpedia.org/data/The_Tin_Drum.jsod\"\n", + "\n", + "data_drum = requests.get(url_drum)\n", + "json_drum = data_drum.json()\n", + "\n", + "print(json.dumps(json_drum, indent=3))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Acessando e navegando pelo Grafo\n", + "### Quem é autor de The Tin Drum?" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Autor de The Tin Drum: http://dbpedia.org/resource/Günter_Grass\n" + ] + } + ], + "source": [ + "grass = json_drum[\"d\"][\"results\"][0][\"http://dbpedia.org/ontology/author\"][\"__deferred\"][\"uri\"]\n", + "print(\"Autor de The Tin Drum: \" + grass)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"d\": {\n", + " \"results\": [\n", + " {\n", + " \"__metadata\": {\n", + " \"uri\": \"http://dbpedia.org/resource/The_Tin_Drum\"\n", + " },\n", + " \"http://www.w3.org/2000/01/rdf-schema#label\": \"Blaszany b\\u0119benek\",\n", + " \"http://www.w3.org/2002/07/owl#sameAs\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"https://global.dbpedia.org/id/54HrW\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/wikiPageWikiLink\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Amanda_Palmer\"\n", + " }\n", + " },\n", + " \"http://www.w3.org/2000/01/rdf-schema#comment\": \"\\u300e\\u30d6\\u30ea\\u30ad\\u306e\\u592a\\u9f13\\u300f\\uff08\\u30d6\\u30ea\\u30ad\\u306e\\u305f\\u3044\\u3053\\u3001Die Blechtrommel\\uff09\\u306f\\u3001\\u30c9\\u30a4\\u30c4\\u306e\\u4f5c\\u5bb6\\u30ae\\u30e5\\u30f3\\u30bf\\u30fc\\u30fb\\u30b0\\u30e9\\u30b9\\u304c1959\\u5e74\\u306b\\u767a\\u8868\\u3057\\u305f\\u51e6\\u5973\\u4f5c\\u3067\\u3042\\u308a\\u9577\\u7bc7\\u5c0f\\u8aac\\u3067\\u3042\\u308b\\u3002\\u300e\\u732b\\u3068\\u9f20\\u300f\\uff081961\\u5e74\\uff09\\u3001\\u300e\\u72ac\\u306e\\u5e74\\u300f\\uff081963\\u5e74\\uff09\\u3068\\u7d9a\\u304f\\u3001\\u3044\\u308f\\u3086\\u308b\\u300c\\u30c0\\u30f3\\u30c4\\u30a3\\u30d2\\u4e09\\u90e8\\u4f5c\\u300d\\u306e\\u6700\\u521d\\u3092\\u98fe\\u308b\\u4f5c\\u54c1\\u3067\\u3042\\u308a\\u3001\\u7b2c\\u4e8c\\u6b21\\u4e16\\u754c\\u5927\\u6226\\u5f8c\\u306e\\u30c9\\u30a4\\u30c4\\u6587\\u5b66\\u306b\\u304a\\u3051\\u308b\\u6700\\u3082\\u91cd\\u8981\\u306a\\u4f5c\\u54c1\\u306e\\u4e00\\u3064\\u306b\\u6570\\u3048\\u3089\\u308c\\u308b\\u30021979\\u5e74\\u306b\\u30d5\\u30a9\\u30eb\\u30ab\\u30fc\\u30fb\\u30b7\\u30e5\\u30ec\\u30f3\\u30c9\\u30eb\\u30d5\\u306b\\u3088\\u3063\\u3066\\u6620\\u753b\\u5316\\u3055\\u308c\\u305f\\u3002\",\n", + " \"http://dbpedia.org/ontology/abstract\": \"Blecktrumman (originaltitel: Die Blechtrommel) \\u00e4r en roman fr\\u00e5n 1959 av G\\u00fcnter Grass. Denna artikel relaterad till sk\\u00f6nlitteratur av en tysk f\\u00f6rfattare saknar v\\u00e4sentlig information. Du kan hj\\u00e4lpa till genom att l\\u00e4gga till den.\",\n", + " \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/class/yago/Disagreement107180787\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/translator\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Breon_Mitchell\"\n", + " }\n", + " },\n", + " \"http://purl.org/dc/elements/1.1/publisher\": \"Hermann Luchterhand Verlag\",\n", + " \"http://dbpedia.org/ontology/numberOfPages\": \"576\",\n", + " \"http://dbpedia.org/ontology/oclc\": \"3618781\",\n", + " \"http://dbpedia.org/property/wikiPageUsesTemplate\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Template:Infobox_book\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/genre\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Magic_realism\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/wikiPageExternalLink\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://www.dieterwunderlich.de/Grass_blechtrommel.htm\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/releaseDate\": \"1959\",\n", + " \"http://dbpedia.org/ontology/wikiPageID\": \"642383\",\n", + " \"http://dbpedia.org/property/dewey\": \"833.914\",\n", + " \"http://dbpedia.org/property/country\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/West_Germany\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/subsequentWork\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Cat_and_Mouse_(novella)\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/series\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Danzig_Trilogy\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/coverArtist\": \"G\\u00fcnter Grass\",\n", + " \"http://dbpedia.org/property/publisher\": \"Hermann Luchterhand Verlag\",\n", + " \"http://dbpedia.org/property/oclc\": \"3618781\",\n", + " \"http://xmlns.com/foaf/0.1/name\": \"Die Blechtrommel\",\n", + " \"http://xmlns.com/foaf/0.1/isPrimaryTopicOf\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://en.wikipedia.org/wiki/The_Tin_Drum\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/titleOrig\": \"Die Blechtrommel\",\n", + " \"http://dbpedia.org/property/caption\": \"Cover of the first German edition\",\n", + " \"http://purl.org/dc/terms/subject\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Category:Novels_about_Nazis\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/name\": \"The Tin Drum\",\n", + " \"http://purl.org/linguistics/gold/hypernym\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Novel\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/wikiPageLength\": \"15013\",\n", + " \"http://dbpedia.org/ontology/dcc\": \"833.914\",\n", + " \"http://www.w3.org/ns/prov#wasDerivedFrom\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://en.wikipedia.org/wiki/The_Tin_Drum?oldid=1012559301&ns=0\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/coverArtist\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/G\\u00fcnter_Grass\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/language\": \"German\",\n", + " \"http://dbpedia.org/property/author\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/G\\u00fcnter_Grass\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/translator\": \"Ralph Manheim, Breon Mitchell\",\n", + " \"http://dbpedia.org/ontology/wikiPageRevisionID\": \"1012559301\",\n", + " \"http://dbpedia.org/ontology/series\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Danzig_Trilogy\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/author\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/G\\u00fcnter_Grass\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/followedBy\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Cat_and_Mouse_(novella)\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/pages\": \"576\",\n", + " \"http://dbpedia.org/ontology/country\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/West_Germany\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/englishReleaseDate\": \"1961\",\n", + " \"http://dbpedia.org/ontology/literaryGenre\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Magic_realism\"\n", + " }\n", + " }\n", + " }\n", + " ],\n", + " \"__count\": \"1\"\n", + " }\n", + "}\n" + ] + } + ], + "source": [ + "url_template = \"http://dbpedia.org/data/{concept}.{format}\"\n", + "\n", + "concept = \"The Tin Drum\"\n", + "format = \"jsod\"\n", + "\n", + "concept = concept.replace(\" \", \"_\")\n", + "\n", + "url = url_template.replace(\"{concept}\", concept)\\\n", + " .replace(\"{format}\", format)\n", + "\n", + "data = requests.get(url)\n", + "js = data.json()\n", + "print(json.dumps(js, indent=3))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Tarefas 1 e 2\n", + "\n", + "As tarefas 1 e 2 descritas no outro notebook devem se basear nos exemplos da DBPedia apresentados acima." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# MeSH - Medical Subject Headings\n", + "\n", + "## Pesquisa para humanos\n", + "\n", + "Através do endereço [MeSH Search](https://meshb.nlm.nih.gov/search).\n", + "\n", + "Procure o termo: Myocardial Infarction.\n", + "\n", + "## Serviços para Máquinas\n", + "\n", + "É possível acessar os mesmos dados pela [API JSON](https://id.nlm.nih.gov/mesh/swagger/ui).\n", + "\n", + "Buscando o código de Myocardial Infarction:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/D009203\",\n", + " \"label\": \"Myocardial Infarction\"\n", + " }\n", + "]\n" + ] + } + ], + "source": [ + "url_template = \"https://id.nlm.nih.gov/mesh/lookup/descriptor?label={concept}&match={match}&limit={limit}\"\n", + "\n", + "concept = \"Myocardial Infarction\"\n", + "match = \"exact\"\n", + "limit = \"10\"\n", + "\n", + "concept = concept.replace(\" \", \"%20\")\n", + "\n", + "url = url_template.replace(\"{concept}\", concept)\\\n", + " .replace(\"{match}\", match)\\\n", + " .replace(\"{limit}\", limit)\n", + "\n", + "data = requests.get(url)\n", + "json_mi = data.json()\n", + "print(json.dumps(json_mi, indent=3))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Acessando o código do recurso:" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "uri do recurso: http://id.nlm.nih.gov/mesh/D009203\n", + "código do recurso: D009203\n" + ] + } + ], + "source": [ + "uri_mesh = json_mi[0][\"resource\"]\n", + "print(\"uri do recurso: \" + uri_mesh)\n", + "bar = str.rindex(uri_mesh, \"/\")\n", + "print(\"código do recurso: \" + uri_mesh[bar+1:])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Acessando detalhes a partir do código:" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"descriptor\": \"http://id.nlm.nih.gov/mesh/D009203\",\n", + " \"terms\": [\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/T027447\",\n", + " \"label\": \"Myocardial Infarction\",\n", + " \"preferred\": true\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/T855594\",\n", + " \"label\": \"Cardiovascular Stroke\",\n", + " \"preferred\": false\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/T000866941\",\n", + " \"label\": \"Heart Attack\",\n", + " \"preferred\": false\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/T027448\",\n", + " \"label\": \"Myocardial Infarct\",\n", + " \"preferred\": false\n", + " }\n", + " ],\n", + " \"qualifiers\": [\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000097\",\n", + " \"label\": \"blood\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000134\",\n", + " \"label\": \"cerebrospinal fluid\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000139\",\n", + " \"label\": \"chemically induced\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000145\",\n", + " \"label\": \"classification\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000150\",\n", + " \"label\": \"complications\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000151\",\n", + " \"label\": \"congenital\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000175\",\n", + " \"label\": \"diagnosis\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000000981\",\n", + " \"label\": \"diagnostic imaging\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000178\",\n", + " \"label\": \"diet therapy\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000188\",\n", + " \"label\": \"drug therapy\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000191\",\n", + " \"label\": \"economics\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000196\",\n", + " \"label\": \"embryology\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000201\",\n", + " \"label\": \"enzymology\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000453\",\n", + " \"label\": \"epidemiology\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000208\",\n", + " \"label\": \"ethnology\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000209\",\n", + " \"label\": \"etiology\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000235\",\n", + " \"label\": \"genetics\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000266\",\n", + " \"label\": \"history\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000276\",\n", + " \"label\": \"immunology\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000378\",\n", + " \"label\": \"metabolism\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000382\",\n", + " \"label\": \"microbiology\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000401\",\n", + " \"label\": \"mortality\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000451\",\n", + " \"label\": \"nursing\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000469\",\n", + " \"label\": \"parasitology\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000473\",\n", + " \"label\": \"pathology\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000503\",\n", + " \"label\": \"physiopathology\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000517\",\n", + " \"label\": \"prevention & control\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000523\",\n", + " \"label\": \"psychology\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000532\",\n", + " \"label\": \"radiotherapy\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000534\",\n", + " \"label\": \"rehabilitation\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000601\",\n", + " \"label\": \"surgery\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000628\",\n", + " \"label\": \"therapy\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000652\",\n", + " \"label\": \"urine\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000662\",\n", + " \"label\": \"veterinary\"\n", + " },\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/Q000821\",\n", + " \"label\": \"virology\"\n", + " }\n", + " ],\n", + " \"seealso\": [\n", + " {\n", + " \"resource\": \"http://id.nlm.nih.gov/mesh/D006342\",\n", + " \"label\": \"Heart Rupture, Post-Infarction\"\n", + " }\n", + " ]\n", + "}\n" + ] + } + ], + "source": [ + "url_template = \"https://id.nlm.nih.gov/mesh/lookup/details?descriptor={code}\"\n", + "\n", + "code = uri_mesh[bar+1:]\n", + "\n", + "url = url_template.replace(\"{code}\", code)\n", + "\n", + "data = requests.get(url)\n", + "json_mid = data.json()\n", + "print(json.dumps(json_mid, indent=3))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Tarefa 3\n", + "\n", + "A tarefas 3 descrita no outro notebook deve se basear nos exemplos do MeSH apresentados acima." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Sequência OpenStreeMap e DBPedia\n", + "\n", + "## REST API do OpenStreetMap para Query" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[\n", + " {\n", + " \"place_id\": 117197145,\n", + " \"licence\": \"Data \\u00a9 OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright\",\n", + " \"osm_type\": \"way\",\n", + " \"osm_id\": 118482151,\n", + " \"boundingbox\": [\n", + " \"51.4785512\",\n", + " \"51.4799711\",\n", + " \"-112.7909406\",\n", + " \"-112.7894948\"\n", + " ],\n", + " \"lat\": \"51.4792159\",\n", + " \"lon\": \"-112.79012880289648\",\n", + " \"display_name\": \"Royal Tyrrell Museum, 1500, North Dinosaur Trail, Nacmine, Drumheller, Alberta, T0J 0Y1, Canada\",\n", + " \"class\": \"tourism\",\n", + " \"type\": \"museum\",\n", + " \"importance\": 0.6921686892957473,\n", + " \"icon\": \"https://nominatim.openstreetmap.org/ui/mapicons//tourist_museum.p.20.png\"\n", + " }\n", + "]\n" + ] + } + ], + "source": [ + "url_template = \"http://nominatim.openstreetmap.org/search?format={format}&q={query}\"\n", + "format = \"json\"\n", + "query = \"Royal Tyrrell Museum\"\n", + "\n", + "url = url_template.replace(\"{format}\", format)\\\n", + " .replace(\"{query}\", query)\n", + "\n", + "data = requests.get(url)\n", + "museum_ref = data.json()\n", + "print(json.dumps(museum_ref, indent=3))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Extraindo o Identificador OSM" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "118482151\n" + ] + } + ], + "source": [ + "print(museum_ref[0][\"osm_id\"])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## REST API do OpenStreetMap para Elementos (Node, Way e Relation)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"version\": \"0.6\",\n", + " \"generator\": \"CGImap 0.8.5 (3009901 spike-06.openstreetmap.org)\",\n", + " \"copyright\": \"OpenStreetMap and contributors\",\n", + " \"attribution\": \"http://www.openstreetmap.org/copyright\",\n", + " \"license\": \"http://opendatacommons.org/licenses/odbl/1-0/\",\n", + " \"elements\": [\n", + " {\n", + " \"type\": \"way\",\n", + " \"id\": 118482151,\n", + " \"timestamp\": \"2019-09-18T22:46:21Z\",\n", + " \"version\": 8,\n", + " \"changeset\": 74647295,\n", + " \"user\": \"Matthew Darwin\",\n", + " \"uid\": 5633991,\n", + " \"nodes\": [\n", + " 1332553185,\n", + " 1332553271,\n", + " 1332553255,\n", + " 1332553305,\n", + " 1332553328,\n", + " 1332553167,\n", + " 1332553161,\n", + " 1332553259,\n", + " 1332553297,\n", + " 1332553188,\n", + " 1332553286,\n", + " 1332553203,\n", + " 1332553376,\n", + " 1332553228,\n", + " 1332553187,\n", + " 1332553223,\n", + " 2424823058,\n", + " 1332553226,\n", + " 1332553212,\n", + " 1332553231,\n", + " 1332553325,\n", + " 1332553350,\n", + " 1332553172,\n", + " 1332553276,\n", + " 1332553344,\n", + " 1332553202,\n", + " 1332553159,\n", + " 1332553250,\n", + " 1332553217,\n", + " 1332553278,\n", + " 1332553324,\n", + " 1332553272,\n", + " 1332553185\n", + " ],\n", + " \"tags\": {\n", + " \"addr:city\": \"Drumheller\",\n", + " \"addr:housenumber\": \"1500\",\n", + " \"addr:street\": \"North Dinosaur Trail\",\n", + " \"alt_name\": \"Royal Tyrrell Museum of Paleontology\",\n", + " \"building\": \"yes\",\n", + " \"museum\": \"paleontology\",\n", + " \"name\": \"Royal Tyrrell Museum\",\n", + " \"tourism\": \"museum\",\n", + " \"website\": \"http://www.tyrrellmuseum.com/\",\n", + " \"wikidata\": \"Q1472318\",\n", + " \"wikipedia\": \"en:Royal Tyrrell Museum of Palaeontology\"\n", + " }\n", + " }\n", + " ]\n", + "}\n" + ] + } + ], + "source": [ + "url_template = \"https://api.openstreetmap.org/api/0.6/{element_type}/{id}.{format}\"\n", + "\n", + "element_type = \"way\" # types: node, way, or relation\n", + "id = str(museum_ref[0][\"osm_id\"])\n", + "format = \"json\"\n", + "\n", + "url = url_template.replace(\"{element_type}\", element_type)\\\n", + " .replace(\"{id}\", id)\\\n", + " .replace(\"{format}\", format)\n", + "\n", + "data = requests.get(url)\n", + "museum_way = data.json()\n", + "print(json.dumps(museum_way, indent=3))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Extraindo o Identificador DBPedia" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "en:Royal Tyrrell Museum of Palaeontology\n" + ] + } + ], + "source": [ + "print(museum_way[\"elements\"][0][\"tags\"][\"wikipedia\"])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## REST API do DBPedia" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"d\": {\n", + " \"results\": [\n", + " {\n", + " \"__metadata\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Royal_Tyrrell_Museum_of_Palaeontology\"\n", + " },\n", + " \"http://dbpedia.org/ontology/wikiPageWikiLink\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Invertebrate\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/wikiPageUsesTemplate\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Template:Cite_journal\"\n", + " }\n", + " },\n", + " \"http://xmlns.com/foaf/0.1/homepage\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"https://tyrrellmuseum.com\"\n", + " }\n", + " },\n", + " \"http://purl.org/dc/terms/subject\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Category:Dinosaur_museums\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/width\": \"97\",\n", + " \"http://www.w3.org/2002/07/owl#sameAs\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://it.dbpedia.org/resource/Royal_Tyrrell_Museum\"\n", + " }\n", + " },\n", + " \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/class/yago/Location100027167\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/wikiPageLength\": \"30034\",\n", + " \"http://www.w3.org/2000/01/rdf-schema#label\": \"Royal Tyrrell Museum of Palaeontology\",\n", + " \"http://www.georss.org/georss/point\": \"51.479166666666664 -112.79\",\n", + " \"http://dbpedia.org/ontology/abstract\": \"\\u30ed\\u30a4\\u30e4\\u30eb\\u30fb\\u30c6\\u30a3\\u30ec\\u30eb\\u53e4\\u751f\\u7269\\u5b66\\u535a\\u7269\\u9928\\uff08\\u30ed\\u30a4\\u30e4\\u30eb\\u30fb\\u30c6\\u30a3\\u30ec\\u30eb\\u3053\\u305b\\u3044\\u3076\\u3064\\u304c\\u304f\\u306f\\u304f\\u3076\\u3064\\u304b\\u3093\\u3001The Royal Tyrrell Museum of Palaeontology\\uff09\\u306f\\u30ab\\u30ca\\u30c0\\u30a2\\u30eb\\u30d0\\u30fc\\u30bf\\u5dde\\u30c9\\u30e9\\u30e0\\u30d8\\u30e9\\u30fc\\u306e\\u30df\\u30c3\\u30c9\\u30e9\\u30f3\\u30c9\\u5dde\\u7acb\\u516c\\u5712\\u5185\\u306b\\u3042\\u308b\\u3001\\u6050\\u7adc\\u3068\\u30d0\\u30fc\\u30b8\\u30a7\\u30b9\\u52d5\\u7269\\u7fa4\\u306e\\u5316\\u77f3\\u306e\\u5c55\\u793a\\u3067\\u4e16\\u754c\\u7684\\u306b\\u6709\\u540d\\u306a\\u535a\\u7269\\u9928\\u3002\\u7279\\u306b\\u3001\\u6050\\u7adc\\u306b\\u95a2\\u3057\\u3066\\u306f\\u305d\\u306e\\u898f\\u6a21\\u306f\\u4e16\\u754c\\u6700\\u5927\\u7d1a\\u3067\\u3042\\u308b\\u3002\",\n", + " \"http://www.w3.org/2000/01/rdf-schema#comment\": \"\\u041a\\u043e\\u0440\\u043e\\u043b\\u0456\\u0432\\u0441\\u044c\\u043a\\u0438\\u0439 \\u0422\\u0438\\u0440\\u0440\\u0435\\u043b\\u0456\\u0432\\u0441\\u044c\\u043a\\u0438\\u0439 \\u043c\\u0443\\u0437\\u0435\\u0439 \\u043f\\u0430\\u043b\\u0435\\u043e\\u043d\\u0442\\u043e\\u043b\\u043e\\u0433\\u0456\\u0457 (\\u0430\\u043d\\u0433\\u043b. Royal Tyrrell Museum) \\u2014 \\u043f\\u0430\\u043b\\u0435\\u043e\\u043d\\u0442\\u043e\\u043b\\u043e\\u0433\\u0456\\u0447\\u043d\\u0438\\u0439 \\u043c\\u0443\\u0437\\u0435\\u0439, \\u0437\\u043d\\u0430\\u0445\\u043e\\u0434\\u0438\\u0442\\u044c\\u0441\\u044f \\u0437\\u0430 4 \\u043a\\u043c \\u0432\\u0456\\u0434 \\u043c\\u0456\\u0441\\u0442\\u0435\\u0447\\u043a\\u0430 \\u0456 \\u043d\\u0430 \\u043f\\u0456\\u0432\\u043d\\u0456\\u0447\\u043d\\u0438\\u0439-\\u0437\\u0430\\u0445\\u0456\\u0434 \\u0432\\u0456\\u0434 \\u043c\\u0456\\u0441\\u0442\\u0430 \\u041a\\u0430\\u043b\\u0433\\u0430\\u0440\\u0456. \\u0404 \\u0433\\u043e\\u043b\\u043e\\u0432\\u043d\\u0438\\u043c \\u043a\\u0430\\u043d\\u0430\\u0434\\u0441\\u044c\\u043a\\u0438\\u043c \\u0446\\u0435\\u043d\\u0442\\u0440\\u043e\\u043c \\u0434\\u043e\\u0441\\u043b\\u0456\\u0434\\u0436\\u0435\\u043d\\u044c \\u0443 \\u0433\\u0430\\u043b\\u0443\\u0437\\u0456 \\u043f\\u0430\\u043b\\u0435\\u043e\\u043d\\u0442\\u043e\\u043b\\u043e\\u0433\\u0456\\u0457 \\u0456 \\u043c\\u0430\\u0454 \\u043f\\u043e\\u043d\\u0430\\u0434 18 000 \\u0441\\u043a\\u0430\\u043c'\\u044f\\u043d\\u0456\\u043b\\u043e\\u0441\\u0442\\u0435\\u0439 \\u0443 \\u043d\\u0430\\u0439\\u0431\\u0456\\u043b\\u044c\\u0448\\u043e\\u043c\\u0443 \\u0441\\u0445\\u043e\\u0432\\u0438\\u0449\\u0456 \\u0432 \\u041a\\u0430\\u043d\\u0430\\u0434\\u0456. \\u0429\\u043e\\u0440\\u0456\\u0447\\u043d\\u043e \\u043c\\u0443\\u0437\\u0435\\u0439 \\u0432\\u0456\\u0434\\u0432\\u0456\\u0434\\u0443\\u044e\\u0442\\u044c 400 \\u0442\\u0438\\u0441\\u044f\\u0447\\u0456 \\u0442\\u0443\\u0440\\u0438\\u0441\\u0442\\u0456\\u0432.\",\n", + " \"http://dbpedia.org/property/type\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Paleontology\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/ontology/wikiPageRevisionID\": \"1024210055\",\n", + " \"http://dbpedia.org/ontology/thumbnail\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://commons.wikimedia.org/wiki/Special:FilePath/Royal_tyrrell_entrance.JPG?width=300\"\n", + " }\n", + " },\n", + " \"http://www.w3.org/2003/01/geo/wgs84_pos#lat\": \"51.47916793823242\",\n", + " \"http://dbpedia.org/ontology/wikiPageExternalLink\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"https://tyrrellmuseum.com\"\n", + " }\n", + " },\n", + " \"http://xmlns.com/foaf/0.1/name\": \"Royal Tyrrell Museum of Palaeontology\",\n", + " \"http://dbpedia.org/ontology/location\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Drumheller\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/website\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"https://tyrrellmuseum.com\"\n", + " }\n", + " },\n", + " \"http://xmlns.com/foaf/0.1/depiction\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://commons.wikimedia.org/wiki/Special:FilePath/Royal_tyrrell_entrance.JPG\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/established\": \"1985-09-25\",\n", + " \"http://www.w3.org/2004/02/skos/core#closeMatch\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://www.grid.ac/institutes/grid.452737.0\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/visitors\": \"470000\",\n", + " \"http://dbpedia.org/property/location\": \"1500\",\n", + " \"http://www.w3.org/2003/01/geo/wgs84_pos#geometry\": \"POINT(-112.79000091553 51.479167938232)\",\n", + " \"http://dbpedia.org/ontology/numberOfVisitors\": \"470000\",\n", + " \"http://dbpedia.org/property/caption\": \"Alxasaurus\",\n", + " \"http://dbpedia.org/property/align\": \"right\",\n", + " \"http://dbpedia.org/property/executiveDirector\": \"Lisa Making\",\n", + " \"http://dbpedia.org/property/image\": \"Alxasaurus Tyrrell.jpg\",\n", + " \"http://www.w3.org/2003/01/geo/wgs84_pos#long\": \"-112.7900009155273\",\n", + " \"http://dbpedia.org/property/owner\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Executive_Council_of_Alberta\"\n", + " }\n", + " },\n", + " \"http://xmlns.com/foaf/0.1/isPrimaryTopicOf\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://en.wikipedia.org/wiki/Royal_Tyrrell_Museum_of_Palaeontology\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/direction\": \"horizontal\",\n", + " \"http://purl.org/linguistics/gold/hypernym\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Attraction\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/formerName\": \"Tyrrell Museum of Palaeontology\",\n", + " \"http://dbpedia.org/property/name\": \"Royal Tyrrell Museum of Palaeontology\",\n", + " \"http://dbpedia.org/property/architect\": \"BCW Architects\",\n", + " \"http://dbpedia.org/ontology/type\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://dbpedia.org/resource/Paleontology\"\n", + " }\n", + " },\n", + " \"http://dbpedia.org/property/footer\": \"-1980.0\",\n", + " \"http://dbpedia.org/ontology/foundingDate\": \"1985-09-25\",\n", + " \"http://dbpedia.org/ontology/wikiPageID\": \"1177220\",\n", + " \"http://schema.org/sameAs\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://viaf.org/viaf/124962175\"\n", + " }\n", + " },\n", + " \"http://www.w3.org/ns/prov#wasDerivedFrom\": {\n", + " \"__deferred\": {\n", + " \"uri\": \"http://en.wikipedia.org/wiki/Royal_Tyrrell_Museum_of_Palaeontology?oldid=1024210055&ns=0\"\n", + " }\n", + " }\n", + " }\n", + " ],\n", + " \"__count\": \"1\"\n", + " }\n", + "}\n" + ] + } + ], + "source": [ + "url_template = \"http://dbpedia.org/data/{concept}.{format}\"\n", + "concept = museum_way[\"elements\"][0][\"tags\"][\"wikipedia\"].replace(\" \", \"_\")\\\n", + " .replace(\"en:\", \"\")\n", + "format = \"jsod\"\n", + "\n", + "url = url_template.replace(\"{concept}\", concept)\\\n", + " .replace(\"{format}\", format)\n", + "\n", + "data = requests.get(url)\n", + "museum_dbpedia = data.json()\n", + "print(json.dumps(museum_dbpedia, indent=3))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Tarefa 4\n", + "\n", + "A tarefa 4 descrita no outro notebook deve se basear nos exemplo de sequência OpenStreeMap/DBPedia apresentado acima." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.10" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/labs/2021/05-services/notebook/lab5-tarefas.ipynb b/labs/2021/05-services/notebook/lab5-tarefas.ipynb new file mode 100644 index 000000000..6c2ff8126 --- /dev/null +++ b/labs/2021/05-services/notebook/lab5-tarefas.ipynb @@ -0,0 +1,104 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "monetary-oakland", + "metadata": {}, + "source": [ + "# Laboratório 5 - Bloco 2\n", + "\n", + "Nas tarefas a seguir o número de células de resposta pode ser aumentado conforme a necessidade." + ] + }, + { + "cell_type": "markdown", + "id": "bridal-netscape", + "metadata": {}, + "source": [ + "## Tarefa 1\n", + "\n", + "### Carregue o nó de Tenda dos Milagres (da versão em inglês Tent of Miracles) em Python e mostre o conteúdo JSON." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "exciting-cement", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "id": "threatened-shepherd", + "metadata": {}, + "source": [ + "## Tarefa 2\n", + "### Recupere via Python e mostre o autor de Tenda dos Milagres?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "subjective-bachelor", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "id": "specialized-playback", + "metadata": {}, + "source": [ + "## Tarefa 3\n", + "### Quais os termos usados para Aspirina (consulta JSON/MeSH em Python)?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "about-sacramento", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "id": "uniform-worst", + "metadata": {}, + "source": [ + "## Tarefa 4\n", + "### Escolha algum lugar no OpenStreetMap e elabore a mesma sequência de três chamadas de serviços para o seu conceito." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "virgin-volunteer", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.10" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/labs/2021/05-services/solucoes/README.md b/labs/2021/05-services/solucoes/README.md new file mode 100644 index 000000000..7de6ce0bc --- /dev/null +++ b/labs/2021/05-services/solucoes/README.md @@ -0,0 +1 @@ +## Dentro desta pasta deve estar a sua solução do laboratório. diff --git a/labs/2021/README.md b/labs/2021/README.md index d289735d0..9f0291849 100644 --- a/labs/2021/README.md +++ b/labs/2021/README.md @@ -6,6 +6,7 @@ * [Laboratório 2](02-data-flow_mvc/) * [Laboratório 3](03-mvc/) * [Laboratório 4](04-messages/) +* [Laboratório 5](05-services/) ## Passos para submissão dos Laboratórios. diff --git a/templates/2021/README.md b/templates/2021/README.md index f6cf2b2af..902c984cb 100644 --- a/templates/2021/README.md +++ b/templates/2021/README.md @@ -8,6 +8,7 @@ Cada laboratório tem seu template que está especificado dentro da respectiva p * [Laboratório 2](lab02/) * [Laboratório 3](lab03/) * [Laboratório 4](lab04/) +* [Laboratório 5](lab05/) Abaixo são dadas orientações gerais para todos os laboratórios. diff --git a/templates/2021/lab05/README.md b/templates/2021/lab05/README.md new file mode 100644 index 000000000..1d422302f --- /dev/null +++ b/templates/2021/lab05/README.md @@ -0,0 +1,25 @@ +# Modelo para Apresentação do Lab05 - Composição, Serviços e REST + +Estrutura de pastas: + +~~~ +├── README.md <- arquivo apresentando a tarefa +│ +└── images <- arquivos de imagens usadas no documento +│ +└── notebook <- arquivo do notebook +~~~ + +# Aluno +* `` + +# Bloco 1 - Diagramas relacionados com Leilão Invertido + +> Coloque as imagens PNG de (no mínimo) três diagramas: +> * diagrama 1 - componentes e barramento +> * diagrama 2 - interface +> * diagrama 3 - mensagens + +# Bloco 2 - Acesso REST via Jupyter + +> Coloque um link para o arquivo do notebook com a resolução das quatro tarefas do mesmo, especificadas em `labs/2021/05-services/notebook/lab5-tarefas.ipynb`. Esse arquivo de resolução ficará dentro da pasta `notebook`. diff --git a/templates/2021/lab05/images/dcc-composition.png b/templates/2021/lab05/images/dcc-composition.png new file mode 100644 index 000000000..e3c041cfa Binary files /dev/null and b/templates/2021/lab05/images/dcc-composition.png differ