diff --git a/docs/practical_examples/knowledge_graph.ipynb b/docs/practical_examples/knowledge_graph.ipynb index bea4f90..6eab062 100644 --- a/docs/practical_examples/knowledge_graph.ipynb +++ b/docs/practical_examples/knowledge_graph.ipynb @@ -170,7 +170,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 16, "id": "064a9e31-1fd0-429e-9189-663e950bc52f", "metadata": {}, "outputs": [], @@ -182,7 +182,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 17, "id": "ce1a26f6-ad59-4014-b5b2-dcee38f11a26", "metadata": {}, "outputs": [], @@ -192,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 18, "id": "78c9adf7-43f0-4aa1-8740-149bf3a5f74f", "metadata": {}, "outputs": [], @@ -203,7 +203,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 21, "id": "e8d13d2e-d66e-4028-8909-7192cfef1bf6", "metadata": {}, "outputs": [ @@ -216,32 +216,64 @@ ] }, { - "ename": "UnicodeEncodeError", - "evalue": "'charmap' codec can't encode characters in position 263607-263621: character maps to ", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mUnicodeEncodeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[1;32mIn[10], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m pyvis_graph\u001b[38;5;241m=\u001b[39m subgraph\u001b[38;5;241m.\u001b[39mbuild_pyvis_graph(notebook\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, style\u001b[38;5;241m=\u001b[39mVIS_STYLE)\n\u001b[0;32m 2\u001b[0m pyvis_graph\u001b[38;5;241m.\u001b[39mcdn_resources \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124min_line\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m----> 3\u001b[0m \u001b[43mpyvis_graph\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mshow\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mgraph.html\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnotebook\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n", - "File \u001b[1;32m~\\anaconda3\\envs\\h5tbx\\lib\\site-packages\\pyvis\\network.py:546\u001b[0m, in \u001b[0;36mNetwork.show\u001b[1;34m(self, name, local, notebook)\u001b[0m\n\u001b[0;32m 544\u001b[0m \u001b[38;5;28mprint\u001b[39m(name)\n\u001b[0;32m 545\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m notebook:\n\u001b[1;32m--> 546\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mwrite_html\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mopen_browser\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43mnotebook\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[0;32m 547\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 548\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mwrite_html(name, open_browser\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n", - "File \u001b[1;32m~\\anaconda3\\envs\\h5tbx\\lib\\site-packages\\pyvis\\network.py:530\u001b[0m, in \u001b[0;36mNetwork.write_html\u001b[1;34m(self, name, local, notebook, open_browser)\u001b[0m\n\u001b[0;32m 528\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcdn_resources \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124min_line\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcdn_resources \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mremote\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m 529\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(getcwd_name, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mw+\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m out:\n\u001b[1;32m--> 530\u001b[0m \u001b[43mout\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mwrite\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhtml\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 531\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 532\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcdn_resources is not in [\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124min_line\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m,\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mremote\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m,\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlocal\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m].\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", - "File \u001b[1;32m~\\anaconda3\\envs\\h5tbx\\lib\\encodings\\cp1252.py:19\u001b[0m, in \u001b[0;36mIncrementalEncoder.encode\u001b[1;34m(self, input, final)\u001b[0m\n\u001b[0;32m 18\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mencode\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;28minput\u001b[39m, final\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m):\n\u001b[1;32m---> 19\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcodecs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcharmap_encode\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43merrors\u001b[49m\u001b[43m,\u001b[49m\u001b[43mencoding_table\u001b[49m\u001b[43m)\u001b[49m[\u001b[38;5;241m0\u001b[39m]\n", - "\u001b[1;31mUnicodeEncodeError\u001b[0m: 'charmap' codec can't encode characters in position 263607-263621: character maps to " - ] + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ "pyvis_graph= subgraph.build_pyvis_graph(notebook=True, style=VIS_STYLE)\n", - "pyvis_graph.cdn_resources = 'in_line'\n", - "pyvis_graph.show('graph.html', notebook=True)" + "pyvis_graph.cdn_resources = 'remote'\n", + "pyvis_graph.show('graph.html', local=False, notebook=True)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "a44f0039-00b8-44c5-b237-ccba12993bdd", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"@context\": {\n", + " \"fname\": \"http://xmlns.com/foaf/0.1/firstName\",\n", + " \"lname\": \"http://xmlns.com/foaf/0.1/lastName\"\n", + " },\n", + " \"@graph\": [\n", + " {\n", + " \"@id\": \"_:N14\",\n", + " \"http://www.w3.org/2004/02/skos/core#definition\": \"A hint\"\n", + " },\n", + " {\n", + " \"@id\": \"http://www.w3.org/ns/prov#Person\",\n", + " \"fname\": \"Matthias\",\n", + " \"lname\": \"Probst\"\n", + " }\n", + " ]\n", + "}\n" + ] + } + ], "source": [ "with h5tbx.File() as h5:\n", " h5.create_dataset(name='test', data=4.3)\n", @@ -259,7 +291,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "id": "3e8834fc-6217-42c3-b442-2565b012f828", "metadata": {}, "outputs": [], @@ -271,7 +303,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "id": "077911e8-8bc3-4b58-a480-df605bdceae4", "metadata": {}, "outputs": [], @@ -286,10 +318,41 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "67f99459-8351-4819-8a67-2b58d4b1e398", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Warning: When cdn_resources is 'local' jupyter notebook has issues displaying graphics on chrome/safari. Use cdn_resources='in_line' or cdn_resources='remote' if you have issues viewing graphics in a notebook.\n", + "tmp.grpah.html\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "kg_from_jsonld = kglab.KnowledgeGraph().load_jsonld('test.jsonld')\n", "\n",