{ "cells": [ { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "import getpass\n", "import os\n", "from langchain_community.graphs import Neo4jGraph\n", "from graphdatascience import GraphDataScience\n", "import pandas as pd\n", "import numpy as np\n", "from langchain_core.prompts import ChatPromptTemplate\n", "from langchain_core.output_parsers import StrOutputParser\n", "#from src.llm import get_llm\n", "\n", "import os\n", "import getpass\n", "from neo4j import GraphDatabase, Result\n", "import pandas as pd\n", "import seaborn as sns\n", "import matplotlib.pyplot as plt\n", "import tiktoken\n", "import numpy as np\n", "from langchain_openai import OpenAIEmbeddings, ChatOpenAI\n", "from langchain_community.vectorstores import Neo4jVector\n", "from langchain_community.graphs import Neo4jGraph\n", "from langchain_core.prompts import ChatPromptTemplate\n", "from langchain_core.output_parsers import StrOutputParser\n", "# from llama_index.core.schema import TextNode\n", "# from llama_index.core.vector_stores.utils import node_to_metadata_dict\n", "# from llama_index.vector_stores.neo4jvector import Neo4jVectorStore\n", "# from llama_index.core import VectorStoreIndex\n", "from tqdm import tqdm\n", "#from src.shared.common_fn import load_embedding_model\n", "\n", "import dotenv\n", "from typing import Dict, Any\n", "from concurrent.futures import ThreadPoolExecutor, as_completed\n", "from tqdm import tqdm\n", "#from src.llm import get_llm" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [], "source": [ "def env_parse(file):\n", " credentials = {}\n", " with open(file, 'r') as f:\n", " for line in f:\n", " if line[0] == '#':\n", " continue\n", " line = line.split('=')\n", " credentials[line[0]] = line[1].strip()\n", " return credentials\n", "credentials = env_parse('Neo4j-f34533c1-Created-2024-11-18.txt')\n", "url = credentials['NEO4J_URI']\n", "username = credentials['NEO4J_USERNAME']\n", "password = credentials['NEO4J_PASSWORD']\n", "url = url.replace('neo4j+s://', 'neo4j+ssc://')" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "os.environ[\"NEO4J_URI\"] = url\n", "os.environ[\"NEO4J_USERNAME\"] = username\n", "os.environ[\"NEO4J_PASSWORD\"] = password\n", "\n", "dotenv.load_dotenv('.env.example')" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[#0000] _: created, routing address IPv4Address(('f34533c1.databases.neo4j.io', 7687))\n", "[#0000] _: resolve home database\n", "[#0000] _: attempting to update routing table from IPv4Address(('f34533c1.databases.neo4j.io', 7687))\n", "[#0000] _: in: f34533c1.databases.neo4j.io:7687\n", "[#0000] _: dns resolver out: 35.241.237.34:7687\n", "[#0000] _: _acquire router connection, database=None, address=ResolvedIPv4Address(('35.241.237.34', 7687))\n", "[#0000] _: trying to hand out new connection\n", "[#0000] C: 35.241.237.34:7687\n", "[#E075] C: f34533c1.databases.neo4j.io\n", "[#E075] C: 0x6060B017\n", "[#E075] C: 0x00070705 0x00020404 0x00000104 0x00000003\n", "[#E075] S: 0x00000605\n", "[#E075] C: HELLO {'user_agent': 'neo4j-graphdatascience-v1.12', 'routing': {'address': 'f34533c1.databases.neo4j.io:7687'}, 'bolt_agent': {'product': 'neo4j-python/5.26.0', 'platform': 'Darwin 23.6.0; arm64', 'language': 'Python/3.11.6-final-0', 'language_details': 'CPython; 3.11.6-final-0 (v3.11.6:8b6ee5ba3b, Oct 2 2023 11:18:21) [Clang 13.0.0 (clang-1300.0.29.30)]'}}\n", "[#E075] _: client state: CONNECTED > AUTHENTICATION\n", "[#E075] C: LOGON {'scheme': 'basic', 'principal': 'neo4j', 'credentials': '*******'}\n", "[#E075] _: client state: AUTHENTICATION > READY\n", "[#E075] S: SUCCESS {'server': 'Neo4j/5.25-aura', 'connection_id': 'bolt-62679', 'hints': {'connection.recv_timeout_seconds': 60, 'telemetry.enabled': True}}\n", "[#E075] _: server state: CONNECTED > AUTHENTICATION\n", "[#E075] S: SUCCESS {}\n", "[#E075] _: server state: AUTHENTICATION > READY\n", "[#E075] C: ROUTE {'address': 'f34533c1.databases.neo4j.io:7687'} () {}\n", "[#E075] S: SUCCESS {'rt': {'servers': [{'addresses': ['f34533c1.databases.neo4j.io:7687'], 'role': 'WRITE'}, {'addresses': ['f34533c1.databases.neo4j.io:7687'], 'role': 'READ'}, {'addresses': ['f34533c1.databases.neo4j.io:7687'], 'role': 'ROUTE'}], 'ttl': 10, 'db': 'neo4j'}}\n", "[#E075] _: released bolt-62679\n", "[#0000] _: updated table=RoutingTable(database='neo4j', routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, readers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, writers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, last_updated_time=773166.308083666, ttl=10)\n", "[#0000] _: update routing table from address=ResolvedIPv4Address(('35.241.237.34', 7687)) (RoutingTable(database='neo4j', routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, readers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, writers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, last_updated_time=773166.308083666, ttl=10))\n", "[#0000] _: acquire routing connection, access_mode='READ', database='neo4j'\n", "[#0000] _: routing aged?, database=None\n", "[#0000] _: purge check: last_updated_time=773166.163261125, ttl=0, perf_time=773166.308928333 => False\n", "[#0000] _: routing aged?, database=neo4j\n", "[#0000] _: purge check: last_updated_time=773166.308083666, ttl=10, perf_time=773166.3093025 => False\n", "[#0000] _: checking table freshness (readonly=True): table expired=False, has_server_for_mode=True, table routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))} => True\n", "[#0000] _: using existing routing table RoutingTable(database='neo4j', routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, readers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, writers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, last_updated_time=773166.308083666, ttl=10)\n", "[#0000] _: acquire address, database='neo4j' address=IPv4Address(('f34533c1.databases.neo4j.io', 7687))\n", "[#0000] _: trying to hand out new connection\n", "[#0000] _: in: f34533c1.databases.neo4j.io:7687\n", "[#0000] _: dns resolver out: 35.241.237.34:7687\n", "[#0000] C: 35.241.237.34:7687\n", "[#E076] C: f34533c1.databases.neo4j.io\n", "[#E076] C: 0x6060B017\n", "[#E076] C: 0x00070705 0x00020404 0x00000104 0x00000003\n", "[#E076] S: 0x00000605\n", "[#E076] C: HELLO {'user_agent': 'neo4j-graphdatascience-v1.12', 'routing': {'address': 'f34533c1.databases.neo4j.io:7687'}, 'bolt_agent': {'product': 'neo4j-python/5.26.0', 'platform': 'Darwin 23.6.0; arm64', 'language': 'Python/3.11.6-final-0', 'language_details': 'CPython; 3.11.6-final-0 (v3.11.6:8b6ee5ba3b, Oct 2 2023 11:18:21) [Clang 13.0.0 (clang-1300.0.29.30)]'}}\n", "[#E076] _: client state: CONNECTED > AUTHENTICATION\n", "[#E076] C: LOGON {'scheme': 'basic', 'principal': 'neo4j', 'credentials': '*******'}\n", "[#E076] _: client state: AUTHENTICATION > READY\n", "[#E076] S: SUCCESS {'server': 'Neo4j/5.25-aura', 'connection_id': 'bolt-62680', 'hints': {'connection.recv_timeout_seconds': 60, 'telemetry.enabled': True}}\n", "[#E076] _: server state: CONNECTED > AUTHENTICATION\n", "[#E076] S: SUCCESS {}\n", "[#E076] _: server state: AUTHENTICATION > READY\n", "[#E076] _: released bolt-62680\n", "[#0000] _: resolve home database\n", "[#0000] _: attempting to update routing table from IPv4Address(('f34533c1.databases.neo4j.io', 7687))\n", "[#0000] _: in: f34533c1.databases.neo4j.io:7687\n", "[#0000] _: dns resolver out: 35.241.237.34:7687\n", "[#0000] _: _acquire router connection, database=None, address=ResolvedIPv4Address(('35.241.237.34', 7687))\n", "[#E075] _: picked existing connection bolt-62679\n", "[#E075] _: checked re_auth auth=None updated=False force=False\n", "[#E075] _: handing out existing connection\n", "[#E075] C: ROUTE {'address': 'f34533c1.databases.neo4j.io:7687'} () {}\n", "[#E075] S: SUCCESS {'rt': {'servers': [{'addresses': ['f34533c1.databases.neo4j.io:7687'], 'role': 'WRITE'}, {'addresses': ['f34533c1.databases.neo4j.io:7687'], 'role': 'READ'}, {'addresses': ['f34533c1.databases.neo4j.io:7687'], 'role': 'ROUTE'}], 'ttl': 10, 'db': 'neo4j'}}\n", "[#E075] _: released bolt-62679\n", "[#0000] _: updated table=RoutingTable(database='neo4j', routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, readers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, writers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, last_updated_time=773166.436566166, ttl=10)\n", "[#0000] _: update routing table from address=ResolvedIPv4Address(('35.241.237.34', 7687)) (RoutingTable(database='neo4j', routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, readers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, writers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, last_updated_time=773166.436566166, ttl=10))\n", "[#0000] _: acquire routing connection, access_mode='WRITE', database='neo4j'\n", "[#0000] _: routing aged?, database=None\n", "[#0000] _: purge check: last_updated_time=773166.163261125, ttl=0, perf_time=773166.437789833 => False\n", "[#0000] _: routing aged?, database=neo4j\n", "[#0000] _: purge check: last_updated_time=773166.436566166, ttl=10, perf_time=773166.438235625 => False\n", "[#0000] _: checking table freshness (readonly=False): table expired=False, has_server_for_mode=True, table routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))} => True\n", "[#0000] _: using existing routing table RoutingTable(database='neo4j', routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, readers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, writers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, last_updated_time=773166.436566166, ttl=10)\n", "[#0000] _: acquire address, database='neo4j' address=IPv4Address(('f34533c1.databases.neo4j.io', 7687))\n", "[#E076] _: picked existing connection bolt-62680\n", "[#E076] _: checked re_auth auth=None updated=False force=False\n", "[#E076] _: handing out existing connection\n", "[#E076] C: TELEMETRY 2 # ()\n", "[#E076] C: RUN 'RETURN gds.version()' {} {'db': 'neo4j'}\n", "[#E076] _: client state: READY > STREAMING\n", "[#E076] C: PULL {'n': 1000}\n", "[#E076] S: SUCCESS {}\n", "[#E076] S: FAILURE {'code': 'Neo.ClientError.Statement.SyntaxError', 'message': 'Unknown function \\'gds.version\\' (line 1, column 8 (offset: 7))\\n\"RETURN gds.version()\"\\n ^'}\n", "[#E076] C: RESET\n", "[#E076] _: client state: STREAMING > READY\n", "[#E076] S: IGNORED\n", "[#E076] S: SUCCESS {}\n", "[#E076] _: server state: FAILED > READY\n", "[#E076] _: released bolt-62680\n", "[#0000] _: close\n", "[#E075] C: GOODBYE\n", "[#E075] C: \n", "[#E076] C: GOODBYE\n", "[#E076] C: \n" ] }, { "ename": "GdsNotFound", "evalue": "The Graph Data Science library is not correctly installed on the Neo4j server.\n Please refer to https://neo4j.com/docs/graph-data-science/current/installation/.\n ", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mCypherSyntaxError\u001b[0m Traceback (most recent call last)", "File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/graphdatascience/query_runner/neo4j_query_runner.py:197\u001b[0m, in \u001b[0;36mNeo4jQueryRunner.server_version\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 196\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 197\u001b[0m server_version_string \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun_cypher\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mRETURN gds.version()\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcustom_error\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[38;5;241m.\u001b[39msqueeze()\n\u001b[1;32m 198\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_server_version \u001b[38;5;241m=\u001b[39m ServerVersion\u001b[38;5;241m.\u001b[39mfrom_string(server_version_string)\n", "File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/graphdatascience/query_runner/neo4j_query_runner.py:126\u001b[0m, in \u001b[0;36mNeo4jQueryRunner.run_cypher\u001b[0;34m(self, query, params, database, custom_error)\u001b[0m\n\u001b[1;32m 125\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 126\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m e\n\u001b[1;32m 128\u001b[0m \u001b[38;5;66;03m# Though pandas support may be experimental in the `neo4j` package, it should always\u001b[39;00m\n\u001b[1;32m 129\u001b[0m \u001b[38;5;66;03m# be supported in the `graphdatascience` package.\u001b[39;00m\n", "File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/graphdatascience/query_runner/neo4j_query_runner.py:121\u001b[0m, in \u001b[0;36mNeo4jQueryRunner.run_cypher\u001b[0;34m(self, query, params, database, custom_error)\u001b[0m\n\u001b[1;32m 120\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 121\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43msession\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mquery\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 122\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n", "File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/neo4j/_sync/work/session.py:327\u001b[0m, in \u001b[0;36mSession.run\u001b[0;34m(self, query, parameters, **kwargs)\u001b[0m\n\u001b[1;32m 326\u001b[0m parameters \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mdict\u001b[39m(parameters \u001b[38;5;129;01mor\u001b[39;00m {}, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m--> 327\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_auto_result\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_run\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 328\u001b[0m \u001b[43m \u001b[49m\u001b[43mquery\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 329\u001b[0m \u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 330\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_config\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdatabase\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 331\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_config\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mimpersonated_user\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 332\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_config\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdefault_access_mode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 333\u001b[0m \u001b[43m \u001b[49m\u001b[43mbookmarks\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 334\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_config\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mnotifications_min_severity\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 335\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_config\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mnotifications_disabled_classifications\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 336\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 338\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_auto_result\n", "File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/neo4j/_sync/work/result.py:231\u001b[0m, in \u001b[0;36mResult._run\u001b[0;34m(self, query, parameters, db, imp_user, access_mode, bookmarks, notifications_min_severity, notifications_disabled_classifications)\u001b[0m\n\u001b[1;32m 230\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_connection\u001b[38;5;241m.\u001b[39msend_all()\n\u001b[0;32m--> 231\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_attach\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", "File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/neo4j/_sync/work/result.py:425\u001b[0m, in \u001b[0;36mResult._attach\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 424\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_attached \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m:\n\u001b[0;32m--> 425\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_connection\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfetch_message\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", "File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/neo4j/_sync/io/_common.py:184\u001b[0m, in \u001b[0;36mConnectionErrorHandler.__getattr__..outer..inner\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 183\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 184\u001b[0m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 185\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (Neo4jError, ServiceUnavailable, SessionExpired) \u001b[38;5;28;01mas\u001b[39;00m exc:\n", "File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/neo4j/_sync/io/_bolt.py:994\u001b[0m, in \u001b[0;36mBolt.fetch_message\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 991\u001b[0m tag, fields \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39minbox\u001b[38;5;241m.\u001b[39mpop(\n\u001b[1;32m 992\u001b[0m hydration_hooks\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mresponses[\u001b[38;5;241m0\u001b[39m]\u001b[38;5;241m.\u001b[39mhydration_hooks\n\u001b[1;32m 993\u001b[0m )\n\u001b[0;32m--> 994\u001b[0m res \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_process_message\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtag\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfields\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 995\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39midle_since \u001b[38;5;241m=\u001b[39m monotonic()\n", "File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/neo4j/_sync/io/_bolt5.py:496\u001b[0m, in \u001b[0;36mBolt5x0._process_message\u001b[0;34m(self, tag, fields)\u001b[0m\n\u001b[1;32m 495\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 496\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mon_failure\u001b[49m\u001b[43m(\u001b[49m\u001b[43msummary_metadata\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43m{\u001b[49m\u001b[43m}\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 497\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (ServiceUnavailable, DatabaseUnavailable):\n", "File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/neo4j/_sync/io/_common.py:254\u001b[0m, in \u001b[0;36mResponse.on_failure\u001b[0;34m(self, metadata)\u001b[0m\n\u001b[1;32m 253\u001b[0m Util\u001b[38;5;241m.\u001b[39mcallback(handler)\n\u001b[0;32m--> 254\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_hydrate_error(metadata)\n", "\u001b[0;31mCypherSyntaxError\u001b[0m: {code: Neo.ClientError.Statement.SyntaxError} {message: Unknown function 'gds.version' (line 1, column 8 (offset: 7))\n\"RETURN gds.version()\"\n ^}", "\nDuring handling of the above exception, another exception occurred:\n", "\u001b[0;31mGdsNotFound\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[33], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m gds \u001b[38;5;241m=\u001b[39m \u001b[43mGraphDataScience\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 2\u001b[0m \u001b[43m \u001b[49m\u001b[43mos\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43menviron\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mNEO4J_URI\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[43mauth\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mos\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43menviron\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mNEO4J_USERNAME\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mos\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43menviron\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mNEO4J_PASSWORD\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[43m)\u001b[49m\n\u001b[1;32m 6\u001b[0m graph \u001b[38;5;241m=\u001b[39m Neo4jGraph() \n\u001b[1;32m 8\u001b[0m driver \u001b[38;5;241m=\u001b[39m GraphDatabase\u001b[38;5;241m.\u001b[39mdriver(os\u001b[38;5;241m.\u001b[39menviron[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNEO4J_URI\u001b[39m\u001b[38;5;124m\"\u001b[39m], auth\u001b[38;5;241m=\u001b[39m(os\u001b[38;5;241m.\u001b[39menviron[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNEO4J_USERNAME\u001b[39m\u001b[38;5;124m\"\u001b[39m], os\u001b[38;5;241m.\u001b[39menviron[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNEO4J_PASSWORD\u001b[39m\u001b[38;5;124m\"\u001b[39m]))\n", "File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/graphdatascience/graph_data_science.py:80\u001b[0m, in \u001b[0;36mGraphDataScience.__init__\u001b[0;34m(self, endpoint, auth, aura_ds, database, arrow, arrow_disable_server_verification, arrow_tls_root_certs, bookmarks, show_progress)\u001b[0m\n\u001b[1;32m 77\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 78\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_query_runner \u001b[38;5;241m=\u001b[39m Neo4jQueryRunner\u001b[38;5;241m.\u001b[39mcreate(endpoint, auth, aura_ds, database, bookmarks, show_progress)\n\u001b[0;32m---> 80\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_server_version \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_query_runner\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mserver_version\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 82\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_server_version \u001b[38;5;241m<\u001b[39m ServerVersion\u001b[38;5;241m.\u001b[39mfrom_string(__min_server_version__):\n\u001b[1;32m 83\u001b[0m warnings\u001b[38;5;241m.\u001b[39mwarn(\n\u001b[1;32m 84\u001b[0m \u001b[38;5;167;01mDeprecationWarning\u001b[39;00m(\n\u001b[1;32m 85\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mClient does not support the given server version `\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_server_version\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m`.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 88\u001b[0m )\n\u001b[1;32m 89\u001b[0m )\n", "File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/graphdatascience/query_runner/neo4j_query_runner.py:208\u001b[0m, in \u001b[0;36mNeo4jQueryRunner.server_version\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 204\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_driver\u001b[38;5;241m.\u001b[39mclose()\n\u001b[1;32m 205\u001b[0m \u001b[38;5;66;03m# if isinstance(endpoint, str):\u001b[39;00m\n\u001b[1;32m 206\u001b[0m \u001b[38;5;66;03m# driver.close()\u001b[39;00m\n\u001b[0;32m--> 208\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m GdsNotFound(\n\u001b[1;32m 209\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"The Graph Data Science library is not correctly installed on the Neo4j server.\u001b[39;00m\n\u001b[1;32m 210\u001b[0m \u001b[38;5;124;03m Please refer to https://neo4j.com/docs/graph-data-science/current/installation/.\u001b[39;00m\n\u001b[1;32m 211\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m 212\u001b[0m )\n\u001b[1;32m 214\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m UnableToConnectError(e)\n", "\u001b[0;31mGdsNotFound\u001b[0m: The Graph Data Science library is not correctly installed on the Neo4j server.\n Please refer to https://neo4j.com/docs/graph-data-science/current/installation/.\n " ] } ], "source": [ "gds = GraphDataScience(\n", " os.environ[\"NEO4J_URI\"],\n", " auth=(os.environ[\"NEO4J_USERNAME\"], os.environ[\"NEO4J_PASSWORD\"])\n", ")\n", "\n", "graph = Neo4jGraph() \n", "\n", "driver = GraphDatabase.driver(os.environ[\"NEO4J_URI\"], auth=(os.environ[\"NEO4J_USERNAME\"], os.environ[\"NEO4J_PASSWORD\"]))" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[#0000] _: acquire routing connection, access_mode='WRITE', database='neo4j'\n", "[#0000] _: routing aged?, database=None\n", "[#0000] _: purge check: last_updated_time=770809.556646708, ttl=0, perf_time=770815.468037708 => False\n", "[#0000] _: routing aged?, database=neo4j\n", "[#0000] _: purge check: last_updated_time=770809.732773416, ttl=10, perf_time=770815.469153333 => False\n", "[#0000] _: checking table freshness (readonly=False): table expired=False, has_server_for_mode=True, table routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))} => True\n", "[#0000] _: using existing routing table RoutingTable(database='neo4j', routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, readers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, writers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, last_updated_time=770809.732773416, ttl=10)\n", "[#0000] _: acquire address, database='neo4j' address=IPv4Address(('f34533c1.databases.neo4j.io', 7687))\n", "[#E630] _: picked existing connection bolt-41724\n", "[#E630] _: checked re_auth auth=None updated=False force=False\n", "[#E630] _: handing out existing connection\n", "[#E630] C: TELEMETRY 3 # ()\n", "[#E630] C: BEGIN {'db': 'neo4j', 'bookmarks': ['FB:kcwQj/3vBULJSNqfgsCc8BWClckCBZA=']}\n", "[#E630] _: client state: READY > TX_READY_OR_TX_STREAMING\n", "[#E630] C: RUN '\\nMATCH (n:`__Entity__`)\\nRETURN \"node\" AS type,\\n count(*) AS total_count,\\n count(n.description) AS non_null_descriptions\\nUNION ALL\\nMATCH (n)-[r:!MENTIONS]->()\\nRETURN \"relationship\" AS type,\\n count(*) AS total_count,\\n count(r.description) AS non_null_descriptions\\n' {} {}\n", "[#E630] C: PULL {'n': 1000}\n", "[#E630] S: SUCCESS {}\n", "[#E630] S: SUCCESS {}\n", "[#E630] _: server state: READY > TX_READY_OR_TX_STREAMING\n", "[#E630] S: SUCCESS {'t_first': 86, 'fields': ['type', 'total_count', 'non_null_descriptions'], 'qid': 0}\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: SUCCESS {'statuses': [{'gql_status': '01G11', 'neo4j_code': 'Neo.ClientNotification.Statement.AggregationSkippedNull', 'status_description': 'warn: null value eliminated in set function', 'diagnostic_record': {'_classification': 'UNRECOGNIZED', '_severity': 'WARNING'}, 'description': 'null value eliminated in set function.', 'title': 'The query contains an aggregation function that skips null values.'}, {'gql_status': '00000', 'status_description': 'note: successful completion'}], 'type': 'r', 't_last': 9, 'db': 'neo4j'}\n", "[#E630] C: COMMIT\n", "[#E630] _: client state: TX_READY_OR_TX_STREAMING > READY\n", "[#E630] S: SUCCESS {'bookmark': 'FB:kcwQj/3vBULJSNqfgsCc8BWClckCBZA='}\n", "[#E630] _: server state: TX_READY_OR_TX_STREAMING > READY\n", "[#E630] _: released bolt-41724\n" ] }, { "data": { "text/plain": [ "[{'type': 'node', 'total_count': 46, 'non_null_descriptions': 0},\n", " {'type': 'relationship', 'total_count': 732, 'non_null_descriptions': 0}]" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "graph.query(\"\"\"\n", "MATCH (n:`__Entity__`)\n", "RETURN \"node\" AS type,\n", " count(*) AS total_count,\n", " count(n.description) AS non_null_descriptions\n", "UNION ALL\n", "MATCH (n)-[r:!MENTIONS]->()\n", "RETURN \"relationship\" AS type,\n", " count(*) AS total_count,\n", " count(r.description) AS non_null_descriptions\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[#0000] _: acquire routing connection, access_mode='WRITE', database='neo4j'\n", "[#0000] _: routing aged?, database=neo4j\n", "[#0000] _: purge check: last_updated_time=770929.350779, ttl=10, perf_time=770942.773201291 => False\n", "[#0000] _: checking table freshness (readonly=False): table expired=True, has_server_for_mode=True, table routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))} => False\n", "[#0000] _: attempting to update routing table from IPv4Address(('f34533c1.databases.neo4j.io', 7687))\n", "[#0000] _: in: f34533c1.databases.neo4j.io:7687\n", "[#0000] _: dns resolver out: 35.241.237.34:7687\n", "[#0000] _: _acquire router connection, database='neo4j', address=ResolvedIPv4Address(('35.241.237.34', 7687))\n", "[#E62F] _: picked existing connection bolt-41723\n", "[#E62F] _: checked re_auth auth=None updated=False force=False\n", "[#E62F] _: handing out existing connection\n", "[#E62F] C: ROUTE {'address': 'f34533c1.databases.neo4j.io:7687'} ('FB:kcwQj/3vBULJSNqfgsCc8BWClckCBZA=',) {'db': 'neo4j'}\n", "[#E62F] S: SUCCESS {'rt': {'servers': [{'addresses': ['f34533c1.databases.neo4j.io:7687'], 'role': 'WRITE'}, {'addresses': ['f34533c1.databases.neo4j.io:7687'], 'role': 'READ'}, {'addresses': ['f34533c1.databases.neo4j.io:7687'], 'role': 'ROUTE'}], 'ttl': 10, 'db': 'neo4j'}}\n", "[#E62F] _: released bolt-41723\n", "[#0000] _: updated table=RoutingTable(database='neo4j', routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, readers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, writers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, last_updated_time=770942.789623125, ttl=10)\n", "[#0000] _: update routing table from address=ResolvedIPv4Address(('35.241.237.34', 7687)) (RoutingTable(database='neo4j', routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, readers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, writers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, last_updated_time=770942.789623125, ttl=10))\n", "[#0000] _: acquire address, database='neo4j' address=IPv4Address(('f34533c1.databases.neo4j.io', 7687))\n", "[#E630] _: picked existing connection bolt-41724\n", "[#E630] _: checked re_auth auth=None updated=False force=False\n", "[#E630] _: handing out existing connection\n", "[#E630] C: TELEMETRY 3 # ()\n", "[#E630] C: BEGIN {'db': 'neo4j', 'bookmarks': ['FB:kcwQj/3vBULJSNqfgsCc8BWClckCBZA=']}\n", "[#E630] _: client state: READY > TX_READY_OR_TX_STREAMING\n", "[#E630] C: RUN '\\nCALL db.labels() YIELD label\\nRETURN label, count(*) AS count\\n' {} {}\n", "[#E630] C: PULL {'n': 1000}\n", "[#E630] S: SUCCESS {}\n", "[#E630] S: SUCCESS {}\n", "[#E630] _: server state: READY > TX_READY_OR_TX_STREAMING\n", "[#E630] S: SUCCESS {'t_first': 22, 'fields': ['label', 'count'], 'qid': 0}\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: SUCCESS {'statuses': [{'gql_status': '00000', 'status_description': 'note: successful completion'}], 'type': 'r', 't_last': 1, 'db': 'neo4j'}\n", "[#E630] C: COMMIT\n", "[#E630] _: client state: TX_READY_OR_TX_STREAMING > READY\n", "[#E630] S: SUCCESS {'bookmark': 'FB:kcwQj/3vBULJSNqfgsCc8BWClckCBZA='}\n", "[#E630] _: server state: TX_READY_OR_TX_STREAMING > READY\n", "[#E630] _: released bolt-41724\n" ] }, { "data": { "text/plain": [ "[{'label': 'TextNode', 'count': 1},\n", " {'label': 'vector', 'count': 1},\n", " {'label': 'Document', 'count': 1},\n", " {'label': 'Chunk', 'count': 1},\n", " {'label': '__Entity__', 'count': 1},\n", " {'label': 'Symptom', 'count': 1},\n", " {'label': 'Transmission', 'count': 1},\n", " {'label': 'Location', 'count': 1},\n", " {'label': 'Event', 'count': 1},\n", " {'label': 'Person', 'count': 1},\n", " {'label': 'Organization', 'count': 1},\n", " {'label': 'Disease', 'count': 1},\n", " {'label': 'Position', 'count': 1},\n", " {'label': 'Group', 'count': 1},\n", " {'label': 'Number', 'count': 1},\n", " {'label': 'Percentage', 'count': 1},\n", " {'label': 'Vaccination', 'count': 1},\n", " {'label': 'Statistic', 'count': 1},\n", " {'label': 'Vaccine', 'count': 1},\n", " {'label': 'Year', 'count': 1},\n", " {'label': 'Country', 'count': 1},\n", " {'label': 'Session', 'count': 1},\n", " {'label': 'Message', 'count': 1},\n", " {'label': 'Region', 'count': 1},\n", " {'label': 'Condition', 'count': 1},\n", " {'label': 'Program', 'count': 1},\n", " {'label': 'Network', 'count': 1},\n", " {'label': 'Initiative', 'count': 1},\n", " {'label': 'Concept', 'count': 1},\n", " {'label': 'Publication', 'count': 1},\n", " {'label': 'Resolution', 'count': 1},\n", " {'label': 'Study', 'count': 1},\n", " {'label': 'Disease_strain', 'count': 1},\n", " {'label': 'Action', 'count': 1},\n", " {'label': 'Demographic', 'count': 1},\n", " {'label': 'Complication', 'count': 1},\n", " {'label': 'Disease strain', 'count': 1},\n", " {'label': 'Medical intervention', 'count': 1},\n", " {'label': 'Virus', 'count': 1},\n", " {'label': 'Animal', 'count': 1},\n", " {'label': 'Node', 'count': 1},\n", " {'label': 'Entity', 'count': 1},\n", " {'label': 'Genomic_feature', 'count': 1},\n", " {'label': 'Activity', 'count': 1},\n", " {'label': 'Place', 'count': 1},\n", " {'label': 'Population', 'count': 1}]" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "graph.query(\"\"\"\n", "CALL db.labels() YIELD label\n", "RETURN label, count(*) AS count\n", "\"\"\")\n" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[#0000] _: acquire routing connection, access_mode='WRITE', database='neo4j'\n", "[#0000] _: routing aged?, database=neo4j\n", "[#0000] _: purge check: last_updated_time=770942.789623125, ttl=10, perf_time=770957.523592875 => False\n", "[#0000] _: checking table freshness (readonly=False): table expired=True, has_server_for_mode=True, table routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))} => False\n", "[#0000] _: attempting to update routing table from IPv4Address(('f34533c1.databases.neo4j.io', 7687))\n", "[#0000] _: in: f34533c1.databases.neo4j.io:7687\n", "[#0000] _: dns resolver out: 35.241.237.34:7687\n", "[#0000] _: _acquire router connection, database='neo4j', address=ResolvedIPv4Address(('35.241.237.34', 7687))\n", "[#E62F] _: picked existing connection bolt-41723\n", "[#E62F] _: checked re_auth auth=None updated=False force=False\n", "[#E62F] _: handing out existing connection\n", "[#E62F] C: ROUTE {'address': 'f34533c1.databases.neo4j.io:7687'} ('FB:kcwQj/3vBULJSNqfgsCc8BWClckCBZA=',) {'db': 'neo4j'}\n", "[#E62F] S: SUCCESS {'rt': {'servers': [{'addresses': ['f34533c1.databases.neo4j.io:7687'], 'role': 'WRITE'}, {'addresses': ['f34533c1.databases.neo4j.io:7687'], 'role': 'READ'}, {'addresses': ['f34533c1.databases.neo4j.io:7687'], 'role': 'ROUTE'}], 'ttl': 10, 'db': 'neo4j'}}\n", "[#E62F] _: released bolt-41723\n", "[#0000] _: updated table=RoutingTable(database='neo4j', routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, readers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, writers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, last_updated_time=770957.542428166, ttl=10)\n", "[#0000] _: update routing table from address=ResolvedIPv4Address(('35.241.237.34', 7687)) (RoutingTable(database='neo4j', routers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, readers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, writers={IPv4Address(('f34533c1.databases.neo4j.io', 7687))}, last_updated_time=770957.542428166, ttl=10))\n", "[#0000] _: acquire address, database='neo4j' address=IPv4Address(('f34533c1.databases.neo4j.io', 7687))\n", "[#E630] _: picked existing connection bolt-41724\n", "[#E630] _: checked re_auth auth=None updated=False force=False\n", "[#E630] _: handing out existing connection\n", "[#E630] C: TELEMETRY 3 # ()\n", "[#E630] C: BEGIN {'db': 'neo4j', 'bookmarks': ['FB:kcwQj/3vBULJSNqfgsCc8BWClckCBZA=']}\n", "[#E630] _: client state: READY > TX_READY_OR_TX_STREAMING\n", "[#E630] C: RUN '\\nCALL db.relationshipTypes() YIELD relationshipType\\nRETURN relationshipType, count(*) AS count\\n' {} {}\n", "[#E630] C: PULL {'n': 1000}\n", "[#E630] S: SUCCESS {}\n", "[#E630] S: SUCCESS {}\n", "[#E630] _: server state: READY > TX_READY_OR_TX_STREAMING\n", "[#E630] S: SUCCESS {'t_first': 20, 'fields': ['relationshipType', 'count'], 'qid': 0}\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: RECORD * 1\n", "[#E630] S: SUCCESS {'statuses': [{'gql_status': '00000', 'status_description': 'note: successful completion'}], 'type': 'r', 't_last': 3, 'db': 'neo4j'}\n", "[#E630] C: COMMIT\n", "[#E630] _: client state: TX_READY_OR_TX_STREAMING > READY\n", "[#E630] S: SUCCESS {'bookmark': 'FB:kcwQj/3vBULJSNqfgsCc8BWClckCBZA='}\n", "[#E630] _: server state: TX_READY_OR_TX_STREAMING > READY\n", "[#E630] _: released bolt-41724\n" ] }, { "data": { "text/plain": [ "[{'relationshipType': 'PART_OF', 'count': 1},\n", " {'relationshipType': 'FIRST_CHUNK', 'count': 1},\n", " {'relationshipType': 'NEXT_CHUNK', 'count': 1},\n", " {'relationshipType': 'SIMILAR', 'count': 1},\n", " {'relationshipType': 'MENTIONS', 'count': 1},\n", " {'relationshipType': 'REPORTED', 'count': 1},\n", " {'relationshipType': 'ACQUIRED', 'count': 1},\n", " {'relationshipType': 'TRAVELED_TO', 'count': 1},\n", " {'relationshipType': 'TREATED_IN', 'count': 1},\n", " {'relationshipType': 'ISOLATING_AT', 'count': 1},\n", " {'relationshipType': 'SPREADING_IN', 'count': 1},\n", " {'relationshipType': 'TRANSFERRED_THROUGH', 'count': 1},\n", " {'relationshipType': 'HAS_SYMPTOM', 'count': 1},\n", " {'relationshipType': 'DECLARED', 'count': 1},\n", " {'relationshipType': 'ENDEMIC_TO', 'count': 1},\n", " {'relationshipType': 'REPORTED_CASES', 'count': 1},\n", " {'relationshipType': 'ROLE', 'count': 1},\n", " {'relationshipType': 'CONFIRMED_CASES', 'count': 1},\n", " {'relationshipType': 'PREVENTS', 'count': 1},\n", " {'relationshipType': 'REQUESTED', 'count': 1},\n", " {'relationshipType': 'TARGET_YEAR', 'count': 1},\n", " {'relationshipType': 'FOCUS_REGION', 'count': 1},\n", " {'relationshipType': 'HAS_CASES', 'count': 1},\n", " {'relationshipType': 'HAS_DEATHS', 'count': 1},\n", " {'relationshipType': 'PERCENTAGE_OF_CASES', 'count': 1},\n", " {'relationshipType': 'PERCENTAGE_OF_DEATHS', 'count': 1},\n", " {'relationshipType': 'HAS_ENTITY', 'count': 1},\n", " {'relationshipType': 'LAST_MESSAGE', 'count': 1},\n", " {'relationshipType': 'NEXT', 'count': 1},\n", " {'relationshipType': 'REPORTEDCASE', 'count': 1},\n", " {'relationshipType': 'INFECTEDWITH', 'count': 1},\n", " {'relationshipType': 'ACQUIREDDISEASE', 'count': 1},\n", " {'relationshipType': 'TREATEDIN', 'count': 1},\n", " {'relationshipType': 'ISOLATINGIN', 'count': 1},\n", " {'relationshipType': 'SPREADINGSINCE', 'count': 1},\n", " {'relationshipType': 'DECLAREDGLOBALHEALTHEMERGENCY', 'count': 1},\n", " {'relationshipType': 'ENDEMICTO', 'count': 1},\n", " {'relationshipType': 'SPREADINGIN', 'count': 1},\n", " {'relationshipType': 'SPREADINGATLOWLEVELS', 'count': 1},\n", " {'relationshipType': 'REPORTEDINTRAVELERS', 'count': 1},\n", " {'relationshipType': 'HASCASES', 'count': 1},\n", " {'relationshipType': 'VACCINECALL', 'count': 1},\n", " {'relationshipType': 'CASES', 'count': 1},\n", " {'relationshipType': 'INCREASE', 'count': 1},\n", " {'relationshipType': 'ESTIMATION', 'count': 1},\n", " {'relationshipType': 'PREVENTION', 'count': 1},\n", " {'relationshipType': 'UNVACCINATEDCHILDREN', 'count': 1},\n", " {'relationshipType': 'FIRSTDOSECOVERAGE', 'count': 1},\n", " {'relationshipType': 'SECONDDOSECOVERAGE', 'count': 1},\n", " {'relationshipType': 'REQUIREDCOVERAGE', 'count': 1},\n", " {'relationshipType': 'STATEMENT', 'count': 1},\n", " {'relationshipType': 'DEATHS', 'count': 1},\n", " {'relationshipType': 'OUTBREAKS', 'count': 1},\n", " {'relationshipType': 'EPIDEMIC', 'count': 1},\n", " {'relationshipType': 'DEATHTOLL', 'count': 1},\n", " {'relationshipType': 'AFFECTEDGROUP', 'count': 1},\n", " {'relationshipType': 'HIGHRISKGROUP', 'count': 1},\n", " {'relationshipType': 'COMPLICATION', 'count': 1},\n", " {'relationshipType': 'THREATENS', 'count': 1},\n", " {'relationshipType': 'ELIMINATED', 'count': 1},\n", " {'relationshipType': 'FREEFROM', 'count': 1},\n", " {'relationshipType': 'OPERATES', 'count': 1},\n", " {'relationshipType': 'FOUNDED', 'count': 1},\n", " {'relationshipType': 'AIMSTOEND', 'count': 1},\n", " {'relationshipType': 'MEMBER', 'count': 1},\n", " {'relationshipType': 'FOLLOWSGUIDELINES', 'count': 1},\n", " {'relationshipType': 'FIGHTSAGAINST', 'count': 1},\n", " {'relationshipType': 'RESPONDSTO', 'count': 1},\n", " {'relationshipType': 'MEMBEROF', 'count': 1},\n", " {'relationshipType': 'DEFINEDBY', 'count': 1},\n", " {'relationshipType': 'PROVIDESINFORMATIONON', 'count': 1},\n", " {'relationshipType': 'PUBLISHESDATAON', 'count': 1},\n", " {'relationshipType': 'HIGHLIGHTS', 'count': 1},\n", " {'relationshipType': 'CONDUCTSANALYSIS', 'count': 1},\n", " {'relationshipType': 'SUPPORTSANALYSIS', 'count': 1},\n", " {'relationshipType': 'COMMENTSON', 'count': 1},\n", " {'relationshipType': 'CONTRIBUTESTO', 'count': 1},\n", " {'relationshipType': 'SHOULDENSUREPREVENTIONANDTREATMENT', 'count': 1},\n", " {'relationshipType': 'HASHIGHPREVALENCE', 'count': 1},\n", " {'relationshipType': 'HASLOWTREATMENTCOVERAGE', 'count': 1},\n", " {'relationshipType': 'AIMSTOCOMBAT', 'count': 1},\n", " {'relationshipType': 'ENGAGEIN', 'count': 1},\n", " {'relationshipType': 'LAUNCH', 'count': 1},\n", " {'relationshipType': 'MONITOR', 'count': 1},\n", " {'relationshipType': 'LOWTREATMENTCOVERAGE', 'count': 1},\n", " {'relationshipType': 'TARGETS', 'count': 1},\n", " {'relationshipType': 'CAUSEDBY', 'count': 1},\n", " {'relationshipType': 'ADOPTEDBY', 'count': 1},\n", " {'relationshipType': 'SETBY', 'count': 1},\n", " {'relationshipType': 'HOSTEDBY', 'count': 1},\n", " {'relationshipType': 'CONDUCTEDBY', 'count': 1},\n", " {'relationshipType': 'COLLABORATEDWITH', 'count': 1},\n", " {'relationshipType': 'ACQUIREDIN', 'count': 1},\n", " {'relationshipType': 'REPORTEDCASES', 'count': 1},\n", " {'relationshipType': 'SUSPECTEDCASES', 'count': 1},\n", " {'relationshipType': 'DECLAREDGLOBALHEALTHEMERGENCYFOR', 'count': 1},\n", " {'relationshipType': 'COMMENTEDON', 'count': 1},\n", " {'relationshipType': 'CALLSFORVACCINEDOSES', 'count': 1},\n", " {'relationshipType': 'HASSUSPECTEDCASES', 'count': 1},\n", " {'relationshipType': 'HASDEATHS', 'count': 1},\n", " {'relationshipType': 'CASESREPORTED', 'count': 1},\n", " {'relationshipType': 'CASESINCREASE', 'count': 1},\n", " {'relationshipType': 'PREVENTSDISEASE', 'count': 1},\n", " {'relationshipType': 'CHILDRENWITHOUTFIRSTDOSE', 'count': 1},\n", " {'relationshipType': 'ADVOCATES', 'count': 1},\n", " {'relationshipType': 'EPIDEMICSREPORTED', 'count': 1},\n", " {'relationshipType': 'SIGNIFICANTEPIDEMICS', 'count': 1},\n", " {'relationshipType': 'NOSIGNIFICANTEPIDEMICS', 'count': 1},\n", " {'relationshipType': 'DEATHSREPORTED', 'count': 1},\n", " {'relationshipType': 'DEATHSREDUCTION', 'count': 1},\n", " {'relationshipType': 'EPIDEMICOCCURREDIN', 'count': 1},\n", " {'relationshipType': 'CAUSEDDEATHS', 'count': 1},\n", " {'relationshipType': 'PRIMARILYAFFECTED', 'count': 1},\n", " {'relationshipType': 'CANCAUSE', 'count': 1},\n", " {'relationshipType': 'ELIMINATEDMEASLESIN', 'count': 1},\n", " {'relationshipType': 'PUBLISHEDJOINTREPORT', 'count': 1},\n", " {'relationshipType': 'FOUNDINGMEMBER', 'count': 1},\n", " {'relationshipType': 'PARTOF', 'count': 1},\n", " {'relationshipType': 'PARTNER', 'count': 1},\n", " {'relationshipType': 'HASMEMBER', 'count': 1},\n", " {'relationshipType': 'AFFECTEDBY', 'count': 1},\n", " {'relationshipType': 'WORKSON', 'count': 1},\n", " {'relationshipType': 'SUPPORTS', 'count': 1},\n", " {'relationshipType': 'PUBLISHEDON', 'count': 1},\n", " {'relationshipType': 'SUPPORTEDBY', 'count': 1},\n", " {'relationshipType': 'LEADS', 'count': 1},\n", " {'relationshipType': 'COMPAREDTO', 'count': 1},\n", " {'relationshipType': 'REPORTEDIN', 'count': 1},\n", " {'relationshipType': 'LOCATEDIN', 'count': 1},\n", " {'relationshipType': 'COMMITTEDTOFIGHTING', 'count': 1},\n", " {'relationshipType': 'LAUNCHES', 'count': 1},\n", " {'relationshipType': 'AIMSTOPREVENT', 'count': 1},\n", " {'relationshipType': 'ORGANIZEDBY', 'count': 1},\n", " {'relationshipType': 'TRAVELEDTO', 'count': 1},\n", " {'relationshipType': 'DECLAREDEMERGENCY', 'count': 1},\n", " {'relationshipType': 'HOLDSPOSITION', 'count': 1},\n", " {'relationshipType': 'CALLEDFOR', 'count': 1},\n", " {'relationshipType': 'TARGETEDFOR', 'count': 1},\n", " {'relationshipType': 'DETECTEDIN', 'count': 1},\n", " {'relationshipType': 'HOSPITALIZEDIN', 'count': 1},\n", " {'relationshipType': 'MUTATIONDETECTEDIN', 'count': 1},\n", " {'relationshipType': 'WORKSIN', 'count': 1},\n", " {'relationshipType': 'CIRCULATINGIN', 'count': 1},\n", " {'relationshipType': 'HOSPITALIZEDAT', 'count': 1},\n", " {'relationshipType': 'SPECULATESON', 'count': 1},\n", " {'relationshipType': 'WORKSTODETECT', 'count': 1},\n", " {'relationshipType': 'COMPARESTO', 'count': 1},\n", " {'relationshipType': 'HOPESTOCONTAIN', 'count': 1},\n", " {'relationshipType': 'DISCUSSES', 'count': 1},\n", " {'relationshipType': 'EXPRESSESCONCERN', 'count': 1},\n", " {'relationshipType': 'WARNSABOUT', 'count': 1},\n", " {'relationshipType': 'OCCURSIN', 'count': 1},\n", " {'relationshipType': 'MUTATEDIN', 'count': 1},\n", " {'relationshipType': 'CAUSES', 'count': 1},\n", " {'relationshipType': 'WORKSAT', 'count': 1},\n", " {'relationshipType': 'HASCASESIN', 'count': 1},\n", " {'relationshipType': 'SICKENS', 'count': 1},\n", " {'relationshipType': 'AFFILIATEDWITH', 'count': 1},\n", " {'relationshipType': 'VARIANTOF', 'count': 1},\n", " {'relationshipType': 'SICKENEDBY', 'count': 1},\n", " {'relationshipType': 'MUTATIONCOMPARISON', 'count': 1},\n", " {'relationshipType': 'DETECTEDTHROUGH', 'count': 1},\n", " {'relationshipType': 'CONDUCTEDAT', 'count': 1},\n", " {'relationshipType': 'OUTBREAKLOCATION', 'count': 1},\n", " {'relationshipType': 'NOEXPOSURE', 'count': 1},\n", " {'relationshipType': 'HASCONTACT', 'count': 1},\n", " {'relationshipType': 'POTENTIALCONTACT', 'count': 1},\n", " {'relationshipType': 'DETECT', 'count': 1},\n", " {'relationshipType': 'RESISTANTTOTESTING', 'count': 1},\n", " {'relationshipType': 'KEPTINDARK', 'count': 1},\n", " {'relationshipType': 'REASONFOR', 'count': 1},\n", " {'relationshipType': 'UNAWAREOF', 'count': 1},\n", " {'relationshipType': 'HOPETODIEOUT', 'count': 1},\n", " {'relationshipType': 'CONCERNAMONG', 'count': 1},\n", " {'relationshipType': 'RISKOFTRANSMISSION', 'count': 1},\n", " {'relationshipType': 'VARIATIONOF', 'count': 1},\n", " {'relationshipType': 'POTENTIALMUTATION', 'count': 1},\n", " {'relationshipType': 'AFFECTS', 'count': 1},\n", " {'relationshipType': 'STUDIEDBY', 'count': 1},\n", " {'relationshipType': 'SICKENED', 'count': 1},\n", " {'relationshipType': 'MUTATIONNOTDETECTEDIN', 'count': 1},\n", " {'relationshipType': 'SURVEILLEDIN', 'count': 1},\n", " {'relationshipType': 'TESTEDIN', 'count': 1},\n", " {'relationshipType': 'HADCONTACT', 'count': 1},\n", " {'relationshipType': 'INCLUDES', 'count': 1},\n", " {'relationshipType': 'ENCOUNTERED', 'count': 1},\n", " {'relationshipType': 'PASSEDON', 'count': 1},\n", " {'relationshipType': 'INFECTED', 'count': 1},\n", " {'relationshipType': 'COMMENTED', 'count': 1},\n", " {'relationshipType': 'CONTACT', 'count': 1},\n", " {'relationshipType': 'COMPARED', 'count': 1},\n", " {'relationshipType': 'ASSOCIATEDWITH', 'count': 1},\n", " {'relationshipType': 'FOR', 'count': 1},\n", " {'relationshipType': 'KEPTINTHEDARKABOUT', 'count': 1},\n", " {'relationshipType': 'HOPEWILLDIEOUT', 'count': 1},\n", " {'relationshipType': 'DISCUSSED', 'count': 1},\n", " {'relationshipType': 'WARNEDABOUT', 'count': 1},\n", " {'relationshipType': 'HASUNDETECTEDCASES', 'count': 1},\n", " {'relationshipType': 'MUTATEDDURING', 'count': 1},\n", " {'relationshipType': 'STUDIES', 'count': 1},\n", " {'relationshipType': 'CIRCULATESIN', 'count': 1},\n", " {'relationshipType': 'FIRSTFOUNDIN', 'count': 1},\n", " {'relationshipType': 'SURVEILLANCEFOR', 'count': 1},\n", " {'relationshipType': 'TESTINGFOR', 'count': 1},\n", " {'relationshipType': 'OUTBREAKIN', 'count': 1},\n", " {'relationshipType': 'CONTACTWITH', 'count': 1},\n", " {'relationshipType': 'RISKTO', 'count': 1},\n", " {'relationshipType': 'HOSPITALIZEDWITH', 'count': 1},\n", " {'relationshipType': 'HASCONDITION', 'count': 1},\n", " {'relationshipType': 'HASPOTENTIALMUTATION', 'count': 1},\n", " {'relationshipType': 'DETECTCASES', 'count': 1},\n", " {'relationshipType': 'RESISTANTTO', 'count': 1},\n", " {'relationshipType': 'RISKOFSPREAD', 'count': 1}]" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "graph.query(\"\"\"\n", "CALL db.relationshipTypes() YIELD relationshipType\n", "RETURN relationshipType, count(*) AS count\n", "\"\"\")\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.FeatureDeprecationWarning} {category: DEPRECATION} {title: This feature is deprecated and will be removed in future versions.} {description: The query used a deprecated field from a procedure. ('schema' returned by 'gds.graph.list' is deprecated.)} {position: line: 1, column: 1, offset: 0} for query: 'CALL gds.graph.list()'\n" ] } ], "source": [ "available_graphs = gds.graph.list()\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "available_graphs.drop([0,1],inplace=True)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
degreeDistributiongraphNamedatabasedatabaseLocationmemoryUsagesizeInBytesnodeCountrelationshipCountconfigurationdensitycreationTimemodificationTimeschemaschemaWithOrientation
\n", "
" ], "text/plain": [ "Empty DataFrame\n", "Columns: [degreeDistribution, graphName, database, databaseLocation, memoryUsage, sizeInBytes, nodeCount, relationshipCount, configuration, density, creationTime, modificationTime, schema, schemaWithOrientation]\n", "Index: []" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "available_graphs" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "available_graphs[\"graphName\"].str.contains('communities', regex=False).any()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.FeatureDeprecationWarning} {category: DEPRECATION} {title: This feature is deprecated and will be removed in future versions.} {description: The query used a deprecated field from a procedure. ('schema' returned by 'gds.graph.drop' is deprecated.)} {position: line: 1, column: 1, offset: 0} for query: 'CALL gds.graph.drop($graph_name, $fail_if_missing, $db_name)'\n" ] }, { "data": { "text/plain": [ "graphName communities\n", "database neo4j\n", "databaseLocation local\n", "memoryUsage \n", "sizeInBytes -1\n", "nodeCount 185\n", "relationshipCount 366\n", "configuration {'relationshipProjection': {'_ALL_': {'aggrega...\n", "density 0.010752\n", "creationTime 2024-08-19T12:41:43.997435629+00:00\n", "modificationTime 2024-08-19T12:41:44.127124307+00:00\n", "schema {'graphProperties': {}, 'nodes': {'__Entity__'...\n", "schemaWithOrientation {'graphProperties': {}, 'nodes': {'__Entity__'...\n", "Name: 0, dtype: object" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gds.graph.drop(\"communities\")" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "G, result = gds.graph.project(\n", " \"communities\", # Graph name\n", " \"__Entity__\", # Node projection\n", " {\n", " \"_ALL_\": {\n", " \"type\": \"*\",\n", " \"orientation\": \"UNDIRECTED\",\n", " \"properties\": {\"weight\": {\"property\": \"*\", \"aggregation\": \"COUNT\"}},\n", " }\n", " },\n", ")" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "nodeProjection {'__Entity__': {'label': '__Entity__', 'proper...\n", "relationshipProjection {'_ALL_': {'aggregation': 'DEFAULT', 'orientat...\n", "graphName communities\n", "nodeCount 185\n", "relationshipCount 366\n", "projectMillis 15\n", "Name: 0, dtype: object" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.FeatureDeprecationWarning} {category: DEPRECATION} {title: This feature is deprecated and will be removed in future versions.} {description: The query used a deprecated field from a procedure. ('schema' returned by 'gds.graph.list' is deprecated.)} {position: line: 1, column: 106, offset: 105} for query: 'CALL gds.graph.list($graph_name) YIELD graphName, nodeCount, relationshipCount, database, configuration, schema, memoryUsage'\n" ] }, { "data": { "text/plain": [ "Graph({'graphName': 'communities', 'nodeCount': 185, 'relationshipCount': 366, 'database': 'neo4j', 'configuration': {'relationshipProjection': {'_ALL_': {'aggregation': 'DEFAULT', 'orientation': 'UNDIRECTED', 'indexInverse': False, 'properties': {'weight': {'aggregation': 'COUNT', 'property': '*', 'defaultValue': None}}, 'type': '*'}}, 'readConcurrency': 4, 'relationshipProperties': {}, 'nodeProperties': {}, 'jobId': 'ced0b057-a717-48d8-8b90-842f6f2aa001', 'nodeProjection': {'__Entity__': {'label': '__Entity__', 'properties': {}}}, 'logProgress': True, 'creationTime': neo4j.time.DateTime(2024, 8, 19, 13, 10, 3, 641071700, tzinfo=), 'validateRelationships': False, 'sudo': False}, 'schema': {'graphProperties': {}, 'nodes': {'__Entity__': {}}, 'relationships': {'_ALL_': {'weight': 'Float (DefaultValue(NaN), PERSISTENT, Aggregation.COUNT)'}}}, 'memoryUsage': '2316 KiB'})" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "G" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'COMMUNITY_PROJECT_NAME'" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\"community_project_name\".upper()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Component count: 14\n", "Component distribution: {'min': 1, 'p5': 1, 'max': 155, 'p999': 155, 'p99': 155, 'p1': 1, 'p10': 1, 'p90': 3, 'p50': 1, 'p25': 1, 'p75': 2, 'p95': 155, 'mean': 12.285714285714286}\n" ] } ], "source": [ "wcc = gds.wcc.stats(G)\n", "print(f\"Component count: {wcc['componentCount']}\")\n", "print(f\"Component distribution: {wcc['componentDistribution']}\")" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "writeMillis 5\n", "nodePropertiesWritten 172\n", "ranLevels 2\n", "didConverge True\n", "nodeCount 172\n", "communityCount 22\n", "communityDistribution {'min': 1, 'p5': 1, 'max': 64, 'p999': 64, 'p9...\n", "modularity 0.678705\n", "modularities [0.6566821889989846, 0.6787052274080039]\n", "postProcessingMillis 3\n", "preProcessingMillis 0\n", "computeMillis 33\n", "configuration {'writeProperty': 'communities', 'theta': 0.01...\n", "Name: 0, dtype: object" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gds.leiden.write(\n", " G,\n", " writeProperty=\"communities\",\n", " includeIntermediateCommunities=True,\n", " relationshipWeightProperty=\"weight\",\n", ")" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "graph.query(\"CREATE CONSTRAINT IF NOT EXISTS FOR (c:__Community__) REQUIRE c.id IS UNIQUE;\")" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'count(*)': 344}]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "graph.query(\"\"\"\n", "MATCH (e:`__Entity__`)\n", "UNWIND range(0, size(e.communities) - 1 , 1) AS index\n", "CALL {\n", " WITH e, index\n", " WITH e, index\n", " WHERE index = 0\n", " MERGE (c:`__Community__` {id: toString(index) + '-' + toString(e.communities[index])})\n", " ON CREATE SET c.level = index\n", " MERGE (e)-[:IN_COMMUNITY]->(c)\n", " RETURN count(*) AS count_0\n", "}\n", "CALL {\n", " WITH e, index\n", " WITH e, index\n", " WHERE index > 0\n", " MERGE (current:`__Community__` {id: toString(index) + '-' + toString(e.communities[index])})\n", " ON CREATE SET current.level = index\n", " MERGE (previous:`__Community__` {id: toString(index - 1) + '-' + toString(e.communities[index - 1])})\n", " ON CREATE SET previous.level = index - 1\n", " MERGE (previous)-[:IN_COMMUNITY]->(current)\n", " RETURN count(*) AS count_1\n", "}\n", "RETURN count(*)\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "graph.query(\"\"\"\n", "MATCH (c:__Community__)<-[:IN_COMMUNITY*]-(:__Entity__)<-[:MENTIONS]-(d:Document)\n", "WITH c, count(distinct d) AS rank\n", "SET c.community_rank = rank;\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
LevelNumber of communities25th Percentile50th Percentile75th Percentile90th Percentile99th PercentileMax
00281.02.03.7513.949.6661
11221.02.08.5017.854.5564
\n", "
" ], "text/plain": [ " Level Number of communities 25th Percentile 50th Percentile \\\n", "0 0 28 1.0 2.0 \n", "1 1 22 1.0 2.0 \n", "\n", " 75th Percentile 90th Percentile 99th Percentile Max \n", "0 3.75 13.9 49.66 61 \n", "1 8.50 17.8 54.55 64 " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", "community_size = graph.query(\n", " \"\"\"\n", "MATCH (c:__Community__)<-[:IN_COMMUNITY*]-(e:__Entity__)\n", "WITH c, count(distinct e) AS entities\n", "RETURN split(c.id, '-')[0] AS level, entities\n", "\"\"\"\n", ")\n", "community_size_df = pd.DataFrame.from_records(community_size)\n", "percentiles_data = []\n", "for level in community_size_df[\"level\"].unique():\n", " subset = community_size_df[community_size_df[\"level\"] == level][\"entities\"]\n", " num_communities = len(subset)\n", " percentiles = np.percentile(subset, [25, 50, 75, 90, 99])\n", " percentiles_data.append(\n", " [\n", " level,\n", " num_communities,\n", " percentiles[0],\n", " percentiles[1],\n", " percentiles[2],\n", " percentiles[3],\n", " percentiles[4],\n", " max(subset)\n", " ]\n", " )\n", "\n", "# Create a DataFrame with the percentiles\n", "percentiles_df = pd.DataFrame(\n", " percentiles_data,\n", " columns=[\n", " \"Level\",\n", " \"Number of communities\",\n", " \"25th Percentile\",\n", " \"50th Percentile\",\n", " \"75th Percentile\",\n", " \"90th Percentile\",\n", " \"99th Percentile\",\n", " \"Max\"\n", " ],\n", ")\n", "percentiles_df\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### community summaries" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "community_info = graph.query(\"\"\"\n", "MATCH (c:`__Community__`)<-[:IN_COMMUNITY*]-(e:__Entity__)\n", "WHERE c.level IN [0,1,4]\n", "WITH c, collect(e ) AS nodes\n", "WHERE size(nodes) > 1\n", "CALL apoc.path.subgraphAll(nodes[0], {\n", "\twhitelistNodes:nodes\n", "})\n", "YIELD relationships\n", "RETURN c.id AS communityId,\n", " [n in nodes | {id: n.id, description: n.description, type: [el in labels(n) WHERE el <> '__Entity__'][0]}] AS nodes,\n", " [r in relationships | {start: startNode(r).id, type: type(r), end: endNode(r).id, description: r.description}] AS rels\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'communityId': '0-36',\n", " 'nodes': [{'id': 'India',\n", " 'description': 'Officially the Republic of India, located in South Asia.',\n", " 'type': 'Country'},\n", " {'id': 'Supreme Court Of India',\n", " 'description': 'Head of the independent judiciary.',\n", " 'type': 'Judiciary'},\n", " {'id': 'Indian National Congress',\n", " 'description': 'Dominated Indian politics until 1977.',\n", " 'type': 'Political party'},\n", " {'id': 'Sindhu',\n", " 'description': 'Name of the Indus River, from which the name India is derived.',\n", " 'type': 'River'},\n", " {'id': 'Food And Agriculture Organization Of The United Nations',\n", " 'description': \"Estimates India's forest cover.\",\n", " 'type': 'Organization'},\n", " {'id': '2013 Forest Survey Of India',\n", " 'description': \"States India's forest cover increased to 69.8 million hectares by 2012.\",\n", " 'type': 'Report'},\n", " {'id': 'Yajnavalkya Smriti',\n", " 'description': 'Prohibited the cutting of trees.',\n", " 'type': 'Literature'},\n", " {'id': 'Kautalyas Arthashastra',\n", " 'description': 'Discusses the need for forest administration.',\n", " 'type': 'Literature'},\n", " {'id': 'Crown Land (Encroachment) Ordinance',\n", " 'description': \"Promulgated in 1840 targeting forests in Britain's Asian colonies.\",\n", " 'type': 'Legislation'},\n", " {'id': 'Indian Forest Act Of 1865',\n", " 'description': \"Established the government's claims over forests.\",\n", " 'type': 'Legislation'},\n", " {'id': 'Forest Act Of 1878',\n", " 'description': 'Gave the British government control over all wastelands, including forests.',\n", " 'type': 'Legislation'},\n", " {'id': 'Sir Dietrich Brandis',\n", " 'description': 'Inspector General of Forests in India from 1864 to 1883.',\n", " 'type': 'Person'},\n", " {'id': 'Indian Ocean',\n", " 'description': 'Ocean bounded by India on the north.',\n", " 'type': 'Ocean'},\n", " {'id': 'Sri Lanka',\n", " 'description': 'Country in the vicinity of India in the Indian Ocean.',\n", " 'type': 'Country'},\n", " {'id': 'Maldives',\n", " 'description': 'Country in the vicinity of India in the Indian Ocean.',\n", " 'type': 'Country'},\n", " {'id': 'Myanmar',\n", " 'description': 'Country sharing land border with India to the east.',\n", " 'type': 'Country'},\n", " {'id': 'Himalayan Mountain Range',\n", " 'description': 'Defines the northern frontiers of India.',\n", " 'type': 'Mountain range'},\n", " {'id': 'China',\n", " 'description': 'Country sharing land border with India to the north.',\n", " 'type': 'Country'},\n", " {'id': 'Bhutan',\n", " 'description': 'Country sharing land border with India to the north.',\n", " 'type': 'Country'},\n", " {'id': 'Nepal',\n", " 'description': 'Country sharing land border with India to the north.',\n", " 'type': 'Country'},\n", " {'id': 'Pakistan',\n", " 'description': 'Country sharing land border with India to the west.',\n", " 'type': 'Country'},\n", " {'id': 'Bangladesh',\n", " 'description': 'Country sharing land border with India to the east.',\n", " 'type': 'Country'},\n", " {'id': 'Ganges',\n", " 'description': 'The longest river originating in India.',\n", " 'type': 'River'},\n", " {'id': 'Western Ghats',\n", " 'description': 'One of the three biodiversity hotspots in India.',\n", " 'type': 'Biodiversity hotspot'},\n", " {'id': 'Eastern Himalayas',\n", " 'description': 'One of the three biodiversity hotspots in India.',\n", " 'type': 'Biodiversity hotspot'},\n", " {'id': 'Indo-Burma Hotspot',\n", " 'description': 'One of the three biodiversity hotspots in India.',\n", " 'type': 'Biodiversity hotspot'},\n", " {'id': 'Forests',\n", " 'description': 'Covers about 24.6% of the total land area.',\n", " 'type': 'Ecosystem'},\n", " {'id': 'Indomalayan Realm',\n", " 'description': 'Geographical realm that includes India.',\n", " 'type': 'Realm'},\n", " {'id': 'World', 'description': None, 'type': None},\n", " {'id': 'Public_Sector', 'description': None, 'type': None},\n", " {'id': 'Gdp', 'description': None, 'type': None},\n", " {'id': 'Economic_Liberalisation', 'description': None, 'type': None},\n", " {'id': 'Gdp_Growth', 'description': None, 'type': None},\n", " {'id': 'Consumer_Market', 'description': None, 'type': None},\n", " {'id': 'Wto', 'description': None, 'type': None},\n", " {'id': 'Ease_Of_Business_Index', 'description': None, 'type': None},\n", " {'id': 'Global_Competitiveness_Index', 'description': None, 'type': None},\n", " {'id': 'Billionaires', 'description': None, 'type': None},\n", " {'id': 'Welfare_State', 'description': None, 'type': None},\n", " {'id': 'Socialist_State', 'description': None, 'type': None},\n", " {'id': 'Social_Welfare_Spending', 'description': None, 'type': None},\n", " {'id': 'Labour_Force', 'description': None, 'type': None},\n", " {'id': 'Fdi', 'description': None, 'type': None},\n", " {'id': 'Free_Trade_Agreements', 'description': None, 'type': None},\n", " {'id': 'Service_Sector', 'description': None, 'type': None},\n", " {'id': 'Stock_Exchanges', 'description': None, 'type': None},\n", " {'id': 'Manufacturing', 'description': None, 'type': None},\n", " {'id': 'Population', 'description': None, 'type': None},\n", " {'id': 'Unemployment', 'description': None, 'type': None},\n", " {'id': 'Savings_Rate', 'description': None, 'type': None},\n", " {'id': 'Arabian Sea',\n", " 'description': 'Sea bounded by India on the northwest.',\n", " 'type': 'Sea'},\n", " {'id': 'Bay Of Bengal',\n", " 'description': 'Bay bounded by India on the southeast.',\n", " 'type': 'Bay'},\n", " {'id': 'Africa',\n", " 'description': 'Continent from which modern humans arrived on the Indian subcontinent.',\n", " 'type': 'Continent'},\n", " {'id': 'Indus Valley Civilisation',\n", " 'description': 'Civilisation that evolved from settled life in the western margins of the Indus river basin.',\n", " 'type': 'Civilization'},\n", " {'id': 'Sanskrit',\n", " 'description': 'Indo-European language that diffused into India from the northwest.',\n", " 'type': 'Language'},\n", " {'id': 'Rigveda',\n", " 'description': 'Ancient hymns recording the dawning of Hinduism in India.',\n", " 'type': 'Text'},\n", " {'id': 'Hinduism',\n", " 'description': 'Major religion in India, with roots in the Rigveda.',\n", " 'type': 'Religion'},\n", " {'id': 'Buddhism',\n", " 'description': 'Religion that arose in India, proclaiming social orders unlinked to heredity.',\n", " 'type': 'Religion'},\n", " {'id': 'Jainism',\n", " 'description': 'Religion that arose in India, proclaiming social orders unlinked to heredity.',\n", " 'type': 'Religion'},\n", " {'id': 'Mughal Empire',\n", " 'description': 'Empire that began in 1526, known for its architecture and relative peace.',\n", " 'type': 'Empire'},\n", " {'id': 'Indian Republic',\n", " 'description': 'India has been a federal republic since 1950.',\n", " 'type': 'Government'}],\n", " 'rels': [{'start': 'India',\n", " 'description': None,\n", " 'type': 'IS_PART_OF',\n", " 'end': 'Indomalayan Realm'},\n", " {'start': 'India',\n", " 'description': 'About 1,900 public sector companies with complete control and ownership of railways, highways, and majority control in various industries.',\n", " 'type': 'HAS',\n", " 'end': 'Public_Sector'},\n", " {'start': 'India',\n", " 'description': \"One of the world's highest number of billionaires.\",\n", " 'type': 'HAS',\n", " 'end': 'Billionaires'},\n", " {'start': 'India',\n", " 'description': \"World's second-largest labour force with 586 million workers.\",\n", " 'type': 'HAS',\n", " 'end': 'Labour_Force'},\n", " {'start': 'India',\n", " 'description': 'Has free trade agreements with several nations and blocs.',\n", " 'type': 'HAS',\n", " 'end': 'Free_Trade_Agreements'},\n", " {'start': 'India',\n", " 'description': \"Bombay Stock Exchange and National Stock Exchange are among the world's largest stock exchanges.\",\n", " 'type': 'HAS',\n", " 'end': 'Stock_Exchanges'},\n", " {'start': 'India',\n", " 'description': \"Nearly 65% of India's population is rural.\",\n", " 'type': 'HAS',\n", " 'end': 'Population'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'RELATES_TO',\n", " 'end': 'Rigveda'},\n", " {'start': 'India',\n", " 'description': 'Member of the World Trade Organization since 1 January 1995.',\n", " 'type': 'MEMBER_OF',\n", " 'end': 'Wto'},\n", " {'start': 'India',\n", " 'description': 'High unemployment and rising income inequality.',\n", " 'type': 'FACES',\n", " 'end': 'Unemployment'},\n", " {'start': 'India',\n", " 'description': 'Adopted broad economic liberalisation in 1991.',\n", " 'type': 'ADOPTED',\n", " 'end': 'Economic_Liberalisation'},\n", " {'start': 'India',\n", " 'description': 'Often considered a welfare state.',\n", " 'type': 'CONSIDERED_AS',\n", " 'end': 'Welfare_State'},\n", " {'start': 'India', 'description': None, 'type': 'NEAR', 'end': 'Sri Lanka'},\n", " {'start': 'India', 'description': None, 'type': 'NEAR', 'end': 'Maldives'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Indian Ocean'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Myanmar'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Himalayan Mountain Range'},\n", " {'start': 'India', 'description': None, 'type': 'BORDERS', 'end': 'China'},\n", " {'start': 'India', 'description': None, 'type': 'BORDERS', 'end': 'Bhutan'},\n", " {'start': 'India', 'description': None, 'type': 'BORDERS', 'end': 'Nepal'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Pakistan'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Bangladesh'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Arabian Sea'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Bay Of Bengal'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'SEPARATED_BY',\n", " 'end': 'Sri Lanka'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'DERIVED_FROM',\n", " 'end': 'Sindhu'},\n", " {'start': 'India',\n", " 'description': \"Estimates India's forest cover.\",\n", " 'type': 'ESTIMATES',\n", " 'end': 'Food And Agriculture Organization Of The United Nations'},\n", " {'start': 'India',\n", " 'description': 'Makes up more than 50% of GDP.',\n", " 'type': 'MAKES_UP',\n", " 'end': 'Service_Sector'},\n", " {'start': 'India',\n", " 'description': 'Fifth-largest economy by nominal GDP and third-largest by purchasing power parity (PPP).',\n", " 'type': 'RANKS_AS',\n", " 'end': 'World'},\n", " {'start': 'India',\n", " 'description': 'Fourth-largest consumer market in the world.',\n", " 'type': 'RANKS_AS',\n", " 'end': 'Consumer_Market'},\n", " {'start': 'India',\n", " 'description': \"World's sixth-largest manufacturer, representing 2.6% of global manufacturing output.\",\n", " 'type': 'RANKS_AS',\n", " 'end': 'Manufacturing'},\n", " {'start': 'India',\n", " 'description': 'Officially declared a socialist state as per the constitution.',\n", " 'type': 'DECLARED_AS',\n", " 'end': 'Socialist_State'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'ORIGIN_OF',\n", " 'end': 'Hinduism'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'ORIGIN_OF',\n", " 'end': 'Buddhism'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'ORIGIN_OF',\n", " 'end': 'Jainism'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'GOVERNED_AS',\n", " 'end': 'Indian Republic'},\n", " {'start': 'India',\n", " 'description': '136th by GDP (nominal) and 125th by GDP (PPP) on a per capita income basis.',\n", " 'type': 'RANKS',\n", " 'end': 'Gdp'},\n", " {'start': 'India',\n", " 'description': '63rd on the Ease of Doing Business index.',\n", " 'type': 'RANKS',\n", " 'end': 'Ease_Of_Business_Index'},\n", " {'start': 'India',\n", " 'description': '40th on the Global Competitiveness Index.',\n", " 'type': 'RANKS',\n", " 'end': 'Global_Competitiveness_Index'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'SHARES_BORDERS_WITH',\n", " 'end': 'Myanmar'},\n", " {'start': 'India',\n", " 'description': 'Overall social welfare spending stood at 8.6% of GDP in 2021-22.',\n", " 'type': 'SPENDING',\n", " 'end': 'Social_Welfare_Spending'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HISTORICAL_EVENT',\n", " 'end': 'Mughal Empire'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'ORIGINATES_IN',\n", " 'end': 'Ganges'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HAS_BIODIVERSITY_HOTSPOT',\n", " 'end': 'Western Ghats'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HAS_BIODIVERSITY_HOTSPOT',\n", " 'end': 'Eastern Himalayas'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HAS_BIODIVERSITY_HOTSPOT',\n", " 'end': 'Indo-Burma Hotspot'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HAS_ECOSYSTEM',\n", " 'end': 'Forests'},\n", " {'start': 'India',\n", " 'description': '6% to 7% since the start of the 21st century.',\n", " 'type': 'AVERAGE_ANNUAL_GROWTH',\n", " 'end': 'Gdp_Growth'},\n", " {'start': 'India',\n", " 'description': 'Foreign direct investment in 2021-22 was $82 billion.',\n", " 'type': 'FOREIGN_DIRECT_INVESTMENT',\n", " 'end': 'Fdi'},\n", " {'start': 'India',\n", " 'description': 'Gross domestic savings rate stood at 29.3% of GDP in 2022.',\n", " 'type': 'GROSS_DOMESTIC_SAVINGS_RATE',\n", " 'end': 'Savings_Rate'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HUMAN_ORIGIN',\n", " 'end': 'Africa'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HISTORICAL_DEVELOPMENT',\n", " 'end': 'Indus Valley Civilisation'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'LANGUAGE_DIFFUSION',\n", " 'end': 'Sanskrit'},\n", " {'start': 'Kautalyas Arthashastra',\n", " 'description': 'Discusses the need for forest administration.',\n", " 'type': 'DISCUSSES',\n", " 'end': 'India'},\n", " {'start': 'Indian Forest Act Of 1865',\n", " 'description': \"Establishes government's claims over forests.\",\n", " 'type': 'ESTABLISHES',\n", " 'end': 'India'},\n", " {'start': 'Crown Land (Encroachment) Ordinance',\n", " 'description': \"Targets forests in Britain's Asian colonies.\",\n", " 'type': 'TARGETS',\n", " 'end': 'India'},\n", " {'start': 'Yajnavalkya Smriti',\n", " 'description': 'Prohibits the cutting of trees.',\n", " 'type': 'PROHIBITS',\n", " 'end': 'India'},\n", " {'start': '2013 Forest Survey Of India',\n", " 'description': 'Reports on forest cover increase.',\n", " 'type': 'REPORTS_ON',\n", " 'end': 'India'},\n", " {'start': 'Supreme Court Of India',\n", " 'description': None,\n", " 'type': 'PART_OF_JUDICIARY',\n", " 'end': 'India'},\n", " {'start': 'Indian National Congress',\n", " 'description': None,\n", " 'type': 'HISTORICALLY_DOMINANT_PARTY',\n", " 'end': 'India'},\n", " {'start': 'Forest Act Of 1878',\n", " 'description': 'Gives control over all wastelands, including forests.',\n", " 'type': 'GIVES_CONTROL',\n", " 'end': 'India'},\n", " {'start': 'Sir Dietrich Brandis',\n", " 'description': 'Inspector General of Forests in India from 1864 to 1883.',\n", " 'type': 'INSPECTOR_GENERAL_OF',\n", " 'end': 'India'}]},\n", " {'communityId': '0-34',\n", " 'nodes': [{'id': 'Constitution Of India',\n", " 'description': 'The supreme law of India, laying down the framework for government institutions and fundamental rights.',\n", " 'type': 'Document'},\n", " {'id': 'Parliament',\n", " 'description': 'Cannot override the Constitution of India.',\n", " 'type': 'Institution'},\n", " {'id': 'Government Of India Act 1935',\n", " 'description': 'Replaced by the Constitution of India.',\n", " 'type': 'Document'},\n", " {'id': 'Constituent Assembly',\n", " 'description': 'Tasked with drafting the Constitution of India.',\n", " 'type': 'Government body'},\n", " {'id': 'M. N. Roy',\n", " 'description': 'Proposed the framework for the Constitution of India.',\n", " 'type': 'Person'},\n", " {'id': 'Republic Day',\n", " 'description': 'Celebrated on 26 January in India to honor the Constitution.',\n", " 'type': 'Event'},\n", " {'id': 'Old Parliament House',\n", " 'description': 'Preserves the original 1950 Constitution in a nitrogen-filled case.',\n", " 'type': 'Location'},\n", " {'id': 'British Government',\n", " 'description': 'Responsible for the external security of India during its dominion status.',\n", " 'type': 'Institution'},\n", " {'id': 'Indian Independence Act 1947',\n", " 'description': 'Repealed by the Constitution of India.',\n", " 'type': 'Document'},\n", " {'id': 'Articles Of The Constitution',\n", " 'description': 'Articles 5, 6, 7, 8, 9, 60, 324, 366, 367, 379, 380, 388, 391, 392, 393, and 394 came into force on 26 November 1949.',\n", " 'type': 'Document'}],\n", " 'rels': [{'start': 'Constitution Of India',\n", " 'description': 'The Constitution is based on the proposal suggested by M. N. Roy.',\n", " 'type': 'BASED_ON',\n", " 'end': 'M. N. Roy'},\n", " {'start': 'Constitution Of India',\n", " 'description': 'The original 1950 Constitution is preserved in a nitrogen-filled case.',\n", " 'type': 'PRESERVED_IN',\n", " 'end': 'Old Parliament House'},\n", " {'start': 'Constitution Of India',\n", " 'description': 'Celebrated on 26 January.',\n", " 'type': 'CELEBRATED_ON',\n", " 'end': 'Republic Day'},\n", " {'start': 'Constitution Of India',\n", " 'description': 'Parliament cannot override the Constitution.',\n", " 'type': 'CANNOT_OVERRIDE',\n", " 'end': 'Parliament'},\n", " {'start': 'Constitution Of India',\n", " 'description': 'Certain articles came into force on 26 November 1949.',\n", " 'type': 'CAME_INTO_FORCE',\n", " 'end': 'Articles Of The Constitution'},\n", " {'start': 'Government Of India Act 1935',\n", " 'description': 'Replaced by the Constitution of India.',\n", " 'type': 'REPLACED_BY',\n", " 'end': 'Constitution Of India'},\n", " {'start': 'British Government',\n", " 'description': 'Responsible for the external security of India during its dominion status.',\n", " 'type': 'RESPONSIBLE_FOR',\n", " 'end': 'Constitution Of India'},\n", " {'start': 'Indian Independence Act 1947',\n", " 'description': 'Repealed by the Constitution of India.',\n", " 'type': 'REPEALED_BY',\n", " 'end': 'Constitution Of India'},\n", " {'start': 'Constituent Assembly',\n", " 'description': None,\n", " 'type': 'DRAFTED_BY',\n", " 'end': 'Constitution Of India'}]},\n", " {'communityId': '0-25',\n", " 'nodes': [{'id': 'President Of India',\n", " 'description': 'The Supreme Commander of the Indian Armed Forces.',\n", " 'type': 'Person'},\n", " {'id': 'Nda',\n", " 'description': 'A coalition of the BJP and its allies governing India since 2014.',\n", " 'type': 'Political alliance'},\n", " {'id': 'Government Of India',\n", " 'description': 'Established a system of national parks and protected areas.',\n", " 'type': 'Government'},\n", " {'id': 'Narendra Modi',\n", " 'description': 'Current Prime Minister of India since 26 May 2014.',\n", " 'type': 'Person'},\n", " {'id': 'New Delhi',\n", " 'description': 'The seat of the Government of India.',\n", " 'type': 'Location'},\n", " {'id': 'Supreme Court',\n", " 'description': 'The highest judicial forum and final court of appeal under the Constitution of India.',\n", " 'type': 'Judiciary'},\n", " {'id': 'Indian Councils Act 1909',\n", " 'description': 'Introduced elections to the Imperial Legislative Council.',\n", " 'type': 'Legislation'},\n", " {'id': 'Government Of India Act 1919',\n", " 'description': 'Expanded the Imperial Legislative Council.',\n", " 'type': 'Legislation'},\n", " {'id': 'National Parks',\n", " 'description': 'Established in 1935 and expanded to nearly 1022 by 2023.',\n", " 'type': 'Protected area'},\n", " {'id': 'Wildlife Protection Act Of 1972',\n", " 'description': 'Enacted for the protection of wildlife.',\n", " 'type': 'Legislation'},\n", " {'id': 'Project Tiger',\n", " 'description': 'Special project for the protection of critical species.',\n", " 'type': 'Conservation project'},\n", " {'id': 'Project Elephant',\n", " 'description': 'Special project for the protection of critical species.',\n", " 'type': 'Conservation project'},\n", " {'id': 'Project Dolphin',\n", " 'description': 'Special project for the protection of critical species.',\n", " 'type': 'Conservation project'}],\n", " 'rels': [{'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'INITIATED',\n", " 'end': 'Project Tiger'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'INITIATED',\n", " 'end': 'Project Elephant'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'INITIATED',\n", " 'end': 'Project Dolphin'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'GOVERNED_BY',\n", " 'end': 'Nda'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'ENACTED',\n", " 'end': 'Wildlife Protection Act Of 1972'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'ESTABLISHED',\n", " 'end': 'National Parks'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'LEAD_BY',\n", " 'end': 'Narendra Modi'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'RESPONSIBLE_TO',\n", " 'end': 'Supreme Court'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'SEATED_IN',\n", " 'end': 'New Delhi'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'HEAD_OF_STATE',\n", " 'end': 'President Of India'},\n", " {'start': 'Indian Councils Act 1909',\n", " 'description': None,\n", " 'type': 'INFLUENCED',\n", " 'end': 'Government Of India'},\n", " {'start': 'Government Of India Act 1919',\n", " 'description': None,\n", " 'type': 'INFLUENCED',\n", " 'end': 'Government Of India'}]},\n", " {'communityId': '0-112',\n", " 'nodes': [{'id': 'Prime Minister Of India',\n", " 'description': 'Holds executive authority and responsibility for national security.',\n", " 'type': 'Person'},\n", " {'id': 'Indian Armed Forces',\n", " 'description': 'The military forces of the Republic of India.',\n", " 'type': 'Organization'},\n", " {'id': 'Indian Army',\n", " 'description': 'One of the three professional uniformed services of the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Indian Navy',\n", " 'description': 'One of the three professional uniformed services of the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Indian Air Force',\n", " 'description': 'One of the three professional uniformed services of the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Central Armed Police Forces',\n", " 'description': 'Supports the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Indian Coast Guard',\n", " 'description': 'Supports the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Special Frontier Force',\n", " 'description': 'Supports the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Strategic Forces Command',\n", " 'description': 'An inter-service command of the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Andaman And Nicobar Command',\n", " 'description': 'An inter-service command of the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Integrated Defence Staff',\n", " 'description': 'An inter-service command of the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Ministry Of Defence',\n", " 'description': 'Manages the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Global Firepower Index',\n", " 'description': 'Ranks the military forces globally.',\n", " 'type': 'Report'},\n", " {'id': 'Armed Forces Flag Day',\n", " 'description': 'Honors armed forces and military personnel annually.',\n", " 'type': 'Event'},\n", " {'id': 'Mauryan Empire',\n", " 'description': 'An ancient Indian empire known for its powerful military.',\n", " 'type': 'Empire'},\n", " {'id': 'Chola Empire',\n", " 'description': 'Known for foreign trade and maritime activity.',\n", " 'type': 'Empire'}],\n", " 'rels': [{'start': 'Prime Minister Of India',\n", " 'description': None,\n", " 'type': 'EXECUTIVE_AUTHORITY',\n", " 'end': 'Indian Armed Forces'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Indian Army'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Indian Navy'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Indian Air Force'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'SUPPORTED_BY',\n", " 'end': 'Central Armed Police Forces'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'SUPPORTED_BY',\n", " 'end': 'Indian Coast Guard'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'SUPPORTED_BY',\n", " 'end': 'Special Frontier Force'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'SUPPORTED_BY',\n", " 'end': 'Strategic Forces Command'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'SUPPORTED_BY',\n", " 'end': 'Andaman And Nicobar Command'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'SUPPORTED_BY',\n", " 'end': 'Integrated Defence Staff'},\n", " {'start': 'Ministry Of Defence',\n", " 'description': None,\n", " 'type': 'MANAGES',\n", " 'end': 'Indian Armed Forces'},\n", " {'start': 'Global Firepower Index',\n", " 'description': None,\n", " 'type': 'RANKS',\n", " 'end': 'Indian Armed Forces'},\n", " {'start': 'Armed Forces Flag Day',\n", " 'description': None,\n", " 'type': 'HONORS',\n", " 'end': 'Indian Armed Forces'},\n", " {'start': 'Mauryan Empire',\n", " 'description': None,\n", " 'type': 'HISTORICAL_REFERENCE',\n", " 'end': 'Indian Armed Forces'},\n", " {'start': 'Chola Empire',\n", " 'description': None,\n", " 'type': 'HISTORICAL_REFERENCE',\n", " 'end': 'Indian Armed Forces'}]},\n", " {'communityId': '0-27',\n", " 'nodes': [{'id': 'Rajya Sabha',\n", " 'description': 'The mostly indirectly elected upper house of Parliament.',\n", " 'type': 'Government body'},\n", " {'id': 'Lok Sabha',\n", " 'description': 'The directly elected lower house of Parliament.',\n", " 'type': 'Government body'},\n", " {'id': 'Union Council Of Ministers',\n", " 'description': 'The executive decision-making committee of the government.',\n", " 'type': 'Government body'}],\n", " 'rels': [{'start': 'Union Council Of Ministers',\n", " 'description': None,\n", " 'type': 'RESPONSIBLE_TO',\n", " 'end': 'Rajya Sabha'},\n", " {'start': 'Union Council Of Ministers',\n", " 'description': None,\n", " 'type': 'RESPONSIBLE_TO',\n", " 'end': 'Lok Sabha'}]},\n", " {'communityId': '0-11',\n", " 'nodes': [{'id': 'Republic Of India',\n", " 'description': 'Has two principal official short names, India and Bharat.',\n", " 'type': 'Country'},\n", " {'id': 'Hindustan',\n", " 'description': 'Commonly used name for the Republic of India.',\n", " 'type': 'Name'}],\n", " 'rels': [{'start': 'Republic Of India',\n", " 'description': None,\n", " 'type': 'HAS_NAME',\n", " 'end': 'Hindustan'}]},\n", " {'communityId': '0-15',\n", " 'nodes': [{'id': 'Bharat',\n", " 'description': 'Another principal official short name of the Republic of India.',\n", " 'type': 'Name'},\n", " {'id': 'Dushyanta',\n", " 'description': 'Father of Bharata, associated with the name Bhāratavarṣa.',\n", " 'type': 'Person'},\n", " {'id': 'Mahabharata',\n", " 'description': 'Epic associated with the name Bharata.',\n", " 'type': 'Literature'}],\n", " 'rels': [{'start': 'Bharat',\n", " 'description': None,\n", " 'type': 'ASSOCIATED_WITH',\n", " 'end': 'Dushyanta'},\n", " {'start': 'Bharat',\n", " 'description': None,\n", " 'type': 'ASSOCIATED_WITH',\n", " 'end': 'Mahabharata'}]},\n", " {'communityId': '0-14',\n", " 'nodes': [{'id': 'Bhāratavarṣa',\n", " 'description': 'Term used in the first century AD, derived from the name of the Vedic community of Bharatas.',\n", " 'type': 'Historical term'},\n", " {'id': 'Bharatas',\n", " 'description': 'Mentioned in the Rigveda as one of the principal kingdoms of the Aryavarta.',\n", " 'type': 'Vedic community'}],\n", " 'rels': [{'start': 'Bhāratavarṣa',\n", " 'description': None,\n", " 'type': 'DERIVED_FROM',\n", " 'end': 'Bharatas'}]},\n", " {'communityId': '0-39',\n", " 'nodes': [{'id': 'Thailand',\n", " 'description': \"Shares maritime borders with India's Andaman and Nicobar Islands.\",\n", " 'type': 'Country'},\n", " {'id': 'Indonesia',\n", " 'description': \"Shares maritime borders with India's Andaman and Nicobar Islands.\",\n", " 'type': 'Country'},\n", " {'id': 'Andaman And Nicobar Islands',\n", " 'description': 'Islands of India sharing a maritime border with Thailand, Myanmar, and Indonesia.',\n", " 'type': 'Island'}],\n", " 'rels': [{'start': 'Andaman And Nicobar Islands',\n", " 'description': None,\n", " 'type': 'MARITIME_BORDER',\n", " 'end': 'Thailand'},\n", " {'start': 'Andaman And Nicobar Islands',\n", " 'description': None,\n", " 'type': 'MARITIME_BORDER',\n", " 'end': 'Indonesia'}]},\n", " {'communityId': '0-52',\n", " 'nodes': [{'id': 'Constituent Assembly Of India',\n", " 'description': 'Adopted the Constitution of India on 26 November 1949.',\n", " 'type': 'Institution'},\n", " {'id': 'Sardar Patel',\n", " 'description': 'Convinced princely states to sign articles of integration with India.',\n", " 'type': 'Person'},\n", " {'id': 'V. P. Menon',\n", " 'description': 'Convinced princely states to sign articles of integration with India.',\n", " 'type': 'Person'}],\n", " 'rels': [{'start': 'Sardar Patel',\n", " 'description': 'Convinced princely states to sign articles of integration.',\n", " 'type': 'CONVINCED',\n", " 'end': 'Constituent Assembly Of India'},\n", " {'start': 'V. P. Menon',\n", " 'description': 'Convinced princely states to sign articles of integration.',\n", " 'type': 'CONVINCED',\n", " 'end': 'Constituent Assembly Of India'}]},\n", " {'communityId': '0-78',\n", " 'nodes': [{'id': 'Fauna Species',\n", " 'description': 'India has an estimated 92,873 species of fauna.',\n", " 'type': 'Fauna'},\n", " {'id': 'Insects',\n", " 'description': 'Major category with 63,423 recorded species.',\n", " 'type': 'Fauna'},\n", " {'id': 'Mammals Count',\n", " 'description': '423 mammals in India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Birds Count',\n", " 'description': '1,233 birds in India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Reptiles Count',\n", " 'description': '526 reptiles in India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Amphibians Count',\n", " 'description': '342 amphibians in India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Fish Count',\n", " 'description': '3,022 fish in India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Endemic Mammals',\n", " 'description': '12.6% of mammals are endemic to India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Endemic Birds',\n", " 'description': '4.5% of birds are endemic to India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Endemic Reptiles',\n", " 'description': '45.8% of reptiles are endemic to India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Endemic Amphibians',\n", " 'description': '55.8% of amphibians are endemic to India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Large Animals',\n", " 'description': 'Includes Indian elephant, Indian rhinoceros, and Gaur.',\n", " 'type': 'Fauna'},\n", " {'id': 'Big Cats',\n", " 'description': 'Includes tiger and lion.',\n", " 'type': 'Fauna'},\n", " {'id': 'Cat Family',\n", " 'description': 'Includes Bengal tiger, Asiatic lion, Indian leopard, snow leopard, and clouded leopard.',\n", " 'type': 'Fauna'},\n", " {'id': 'Representative Species',\n", " 'description': 'Includes blackbuck, nilgai, bharal, barasingha, Nilgiri tahr, and Nilgiri langur.',\n", " 'type': 'Fauna'},\n", " {'id': 'Aquatic Mammals',\n", " 'description': 'Includes dolphins, whales, porpoises, and dugong.',\n", " 'type': 'Fauna'},\n", " {'id': 'Reptiles Species',\n", " 'description': 'Includes gharial and saltwater crocodiles.',\n", " 'type': 'Fauna'},\n", " {'id': 'Birds Species',\n", " 'description': 'Includes peafowl, pheasants, geese, ducks, mynas, parakeets, pigeons, cranes, hornbills, and sunbirds.',\n", " 'type': 'Fauna'},\n", " {'id': 'Endemic Bird Species',\n", " 'description': 'Includes great Indian hornbill, great Indian bustard, nicobar pigeon, ruddy shelduck, Himalayan monal, and Himalayan quail.',\n", " 'type': 'Fauna'}],\n", " 'rels': [{'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Insects'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Mammals Count'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Birds Count'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Reptiles Count'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Amphibians Count'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Fish Count'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Endemic Mammals'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Endemic Birds'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Endemic Reptiles'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Endemic Amphibians'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Large Animals'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Big Cats'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Cat Family'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Representative Species'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Aquatic Mammals'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Reptiles Species'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Birds Species'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Endemic Bird Species'}]},\n", " {'communityId': '0-110',\n", " 'nodes': [{'id': 'Plant Species',\n", " 'description': 'About 29,015 species of plants.',\n", " 'type': 'Flora'},\n", " {'id': 'Flowering Plants Count',\n", " 'description': '17,926 species of flowering plants.',\n", " 'type': 'Flora'},\n", " {'id': 'Endemic Plant Species',\n", " 'description': '6,842 species are endemic to India.',\n", " 'type': 'Flora'},\n", " {'id': 'Algae', 'description': '7,244 species.', 'type': 'Flora'},\n", " {'id': 'Bryophytes', 'description': '2,504 species.', 'type': 'Flora'},\n", " {'id': 'Pteridophytes', 'description': '1,267 species.', 'type': 'Flora'},\n", " {'id': 'Gymnosperms', 'description': '74 species.', 'type': 'Flora'},\n", " {'id': 'Fungal Diversity',\n", " 'description': 'Over 27,000 recorded species.',\n", " 'type': 'Flora'},\n", " {'id': 'Flora', 'description': None, 'type': None}],\n", " 'rels': [{'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Plant Species'},\n", " {'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Flowering Plants Count'},\n", " {'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Endemic Plant Species'},\n", " {'start': 'Flora', 'description': None, 'type': 'INCLUDES', 'end': 'Algae'},\n", " {'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Bryophytes'},\n", " {'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Pteridophytes'},\n", " {'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Gymnosperms'},\n", " {'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Fungal Diversity'}]},\n", " {'communityId': '0-105',\n", " 'nodes': [{'id': 'Threatened Species',\n", " 'description': '172 IUCN-designated threatened species.',\n", " 'type': 'Fauna'},\n", " {'id': 'Threatened Mammals',\n", " 'description': '39 species of mammals.',\n", " 'type': 'Fauna'},\n", " {'id': 'Threatened Birds',\n", " 'description': '72 species of birds.',\n", " 'type': 'Fauna'},\n", " {'id': 'Threatened Reptiles',\n", " 'description': '17 species of reptiles.',\n", " 'type': 'Fauna'},\n", " {'id': 'Threatened Amphibians',\n", " 'description': '3 species of amphibians.',\n", " 'type': 'Fauna'},\n", " {'id': 'Threatened Fish',\n", " 'description': '2 species of fish.',\n", " 'type': 'Fauna'}],\n", " 'rels': [{'start': 'Threatened Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Threatened Mammals'},\n", " {'start': 'Threatened Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Threatened Birds'},\n", " {'start': 'Threatened Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Threatened Reptiles'},\n", " {'start': 'Threatened Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Threatened Amphibians'},\n", " {'start': 'Threatened Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Threatened Fish'}]},\n", " {'communityId': '0-125',\n", " 'nodes': [{'id': 'Department Of Defence Production',\n", " 'description': 'Responsible for indigenous production of equipment for the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Make In India Initiative',\n", " 'description': 'Seeks to indigenise manufacturing and reduce dependence on imports for defence.',\n", " 'type': 'Program'}],\n", " 'rels': [{'start': 'Make In India Initiative',\n", " 'description': None,\n", " 'type': 'SUPPORTS',\n", " 'end': 'Department Of Defence Production'}]},\n", " {'communityId': '0-169',\n", " 'nodes': [{'id': 'Maurya Empire',\n", " 'description': 'Ancient empire based in the Ganges Basin.',\n", " 'type': 'Empire'},\n", " {'id': 'Gupta Empire',\n", " 'description': 'Ancient empire based in the Ganges Basin.',\n", " 'type': 'Empire'},\n", " {'id': 'Ganges Basin', 'description': None, 'type': None}],\n", " 'rels': [{'start': 'Ganges Basin',\n", " 'description': None,\n", " 'type': 'BASED_IN',\n", " 'end': 'Maurya Empire'},\n", " {'start': 'Ganges Basin',\n", " 'description': None,\n", " 'type': 'BASED_IN',\n", " 'end': 'Gupta Empire'}]},\n", " {'communityId': '0-170',\n", " 'nodes': [{'id': 'Vijayanagara Empire',\n", " 'description': 'Empire in south India that created a composite Hindu culture.',\n", " 'type': 'Empire'},\n", " {'id': 'South India', 'description': None, 'type': None}],\n", " 'rels': [{'start': 'South India',\n", " 'description': None,\n", " 'type': 'BASED_IN',\n", " 'end': 'Vijayanagara Empire'}]},\n", " {'communityId': '0-171',\n", " 'nodes': [{'id': 'Sikhism',\n", " 'description': 'Religion that emerged in the Punjab, rejecting institutionalised religion.',\n", " 'type': 'Religion'},\n", " {'id': 'Punjab', 'description': None, 'type': None}],\n", " 'rels': [{'start': 'Punjab',\n", " 'description': None,\n", " 'type': 'ORIGIN_OF',\n", " 'end': 'Sikhism'}]},\n", " {'communityId': '0-167',\n", " 'nodes': [{'id': 'British East India Company',\n", " 'description': 'Company that expanded rule in India, turning it into a colonial economy.',\n", " 'type': 'Company'},\n", " {'id': 'British Crown',\n", " 'description': 'Began rule in India in 1858.',\n", " 'type': 'Government'},\n", " {'id': 'Indian Independence',\n", " 'description': 'Event in 1947 when India was partitioned into two independent dominions.',\n", " 'type': 'Event'}],\n", " 'rels': [{'start': 'British East India Company',\n", " 'description': None,\n", " 'type': 'HISTORICAL_EVENT',\n", " 'end': 'British Crown'},\n", " {'start': 'British Crown',\n", " 'description': None,\n", " 'type': 'HISTORICAL_EVENT',\n", " 'end': 'Indian Independence'}]},\n", " {'communityId': '1-23',\n", " 'nodes': [{'id': 'India',\n", " 'description': 'Officially the Republic of India, located in South Asia.',\n", " 'type': 'Country'},\n", " {'id': 'Supreme Court Of India',\n", " 'description': 'Head of the independent judiciary.',\n", " 'type': 'Judiciary'},\n", " {'id': 'Indian National Congress',\n", " 'description': 'Dominated Indian politics until 1977.',\n", " 'type': 'Political party'},\n", " {'id': 'Sindhu',\n", " 'description': 'Name of the Indus River, from which the name India is derived.',\n", " 'type': 'River'},\n", " {'id': 'Food And Agriculture Organization Of The United Nations',\n", " 'description': \"Estimates India's forest cover.\",\n", " 'type': 'Organization'},\n", " {'id': '2013 Forest Survey Of India',\n", " 'description': \"States India's forest cover increased to 69.8 million hectares by 2012.\",\n", " 'type': 'Report'},\n", " {'id': 'Yajnavalkya Smriti',\n", " 'description': 'Prohibited the cutting of trees.',\n", " 'type': 'Literature'},\n", " {'id': 'Kautalyas Arthashastra',\n", " 'description': 'Discusses the need for forest administration.',\n", " 'type': 'Literature'},\n", " {'id': 'Crown Land (Encroachment) Ordinance',\n", " 'description': \"Promulgated in 1840 targeting forests in Britain's Asian colonies.\",\n", " 'type': 'Legislation'},\n", " {'id': 'Indian Forest Act Of 1865',\n", " 'description': \"Established the government's claims over forests.\",\n", " 'type': 'Legislation'},\n", " {'id': 'Forest Act Of 1878',\n", " 'description': 'Gave the British government control over all wastelands, including forests.',\n", " 'type': 'Legislation'},\n", " {'id': 'Sir Dietrich Brandis',\n", " 'description': 'Inspector General of Forests in India from 1864 to 1883.',\n", " 'type': 'Person'},\n", " {'id': 'Indian Ocean',\n", " 'description': 'Ocean bounded by India on the north.',\n", " 'type': 'Ocean'},\n", " {'id': 'Sri Lanka',\n", " 'description': 'Country in the vicinity of India in the Indian Ocean.',\n", " 'type': 'Country'},\n", " {'id': 'Maldives',\n", " 'description': 'Country in the vicinity of India in the Indian Ocean.',\n", " 'type': 'Country'},\n", " {'id': 'Myanmar',\n", " 'description': 'Country sharing land border with India to the east.',\n", " 'type': 'Country'},\n", " {'id': 'Himalayan Mountain Range',\n", " 'description': 'Defines the northern frontiers of India.',\n", " 'type': 'Mountain range'},\n", " {'id': 'China',\n", " 'description': 'Country sharing land border with India to the north.',\n", " 'type': 'Country'},\n", " {'id': 'Bhutan',\n", " 'description': 'Country sharing land border with India to the north.',\n", " 'type': 'Country'},\n", " {'id': 'Nepal',\n", " 'description': 'Country sharing land border with India to the north.',\n", " 'type': 'Country'},\n", " {'id': 'Pakistan',\n", " 'description': 'Country sharing land border with India to the west.',\n", " 'type': 'Country'},\n", " {'id': 'Bangladesh',\n", " 'description': 'Country sharing land border with India to the east.',\n", " 'type': 'Country'},\n", " {'id': 'Ganges',\n", " 'description': 'The longest river originating in India.',\n", " 'type': 'River'},\n", " {'id': 'Western Ghats',\n", " 'description': 'One of the three biodiversity hotspots in India.',\n", " 'type': 'Biodiversity hotspot'},\n", " {'id': 'Eastern Himalayas',\n", " 'description': 'One of the three biodiversity hotspots in India.',\n", " 'type': 'Biodiversity hotspot'},\n", " {'id': 'Indo-Burma Hotspot',\n", " 'description': 'One of the three biodiversity hotspots in India.',\n", " 'type': 'Biodiversity hotspot'},\n", " {'id': 'Forests',\n", " 'description': 'Covers about 24.6% of the total land area.',\n", " 'type': 'Ecosystem'},\n", " {'id': 'Indomalayan Realm',\n", " 'description': 'Geographical realm that includes India.',\n", " 'type': 'Realm'},\n", " {'id': 'World', 'description': None, 'type': None},\n", " {'id': 'Public_Sector', 'description': None, 'type': None},\n", " {'id': 'Gdp', 'description': None, 'type': None},\n", " {'id': 'Economic_Liberalisation', 'description': None, 'type': None},\n", " {'id': 'Gdp_Growth', 'description': None, 'type': None},\n", " {'id': 'Consumer_Market', 'description': None, 'type': None},\n", " {'id': 'Wto', 'description': None, 'type': None},\n", " {'id': 'Ease_Of_Business_Index', 'description': None, 'type': None},\n", " {'id': 'Global_Competitiveness_Index', 'description': None, 'type': None},\n", " {'id': 'Billionaires', 'description': None, 'type': None},\n", " {'id': 'Welfare_State', 'description': None, 'type': None},\n", " {'id': 'Socialist_State', 'description': None, 'type': None},\n", " {'id': 'Social_Welfare_Spending', 'description': None, 'type': None},\n", " {'id': 'Labour_Force', 'description': None, 'type': None},\n", " {'id': 'Fdi', 'description': None, 'type': None},\n", " {'id': 'Free_Trade_Agreements', 'description': None, 'type': None},\n", " {'id': 'Service_Sector', 'description': None, 'type': None},\n", " {'id': 'Stock_Exchanges', 'description': None, 'type': None},\n", " {'id': 'Manufacturing', 'description': None, 'type': None},\n", " {'id': 'Population', 'description': None, 'type': None},\n", " {'id': 'Unemployment', 'description': None, 'type': None},\n", " {'id': 'Savings_Rate', 'description': None, 'type': None},\n", " {'id': 'Arabian Sea',\n", " 'description': 'Sea bounded by India on the northwest.',\n", " 'type': 'Sea'},\n", " {'id': 'Bay Of Bengal',\n", " 'description': 'Bay bounded by India on the southeast.',\n", " 'type': 'Bay'},\n", " {'id': 'Africa',\n", " 'description': 'Continent from which modern humans arrived on the Indian subcontinent.',\n", " 'type': 'Continent'},\n", " {'id': 'Indus Valley Civilisation',\n", " 'description': 'Civilisation that evolved from settled life in the western margins of the Indus river basin.',\n", " 'type': 'Civilization'},\n", " {'id': 'Sanskrit',\n", " 'description': 'Indo-European language that diffused into India from the northwest.',\n", " 'type': 'Language'},\n", " {'id': 'Rigveda',\n", " 'description': 'Ancient hymns recording the dawning of Hinduism in India.',\n", " 'type': 'Text'},\n", " {'id': 'Hinduism',\n", " 'description': 'Major religion in India, with roots in the Rigveda.',\n", " 'type': 'Religion'},\n", " {'id': 'Buddhism',\n", " 'description': 'Religion that arose in India, proclaiming social orders unlinked to heredity.',\n", " 'type': 'Religion'},\n", " {'id': 'Jainism',\n", " 'description': 'Religion that arose in India, proclaiming social orders unlinked to heredity.',\n", " 'type': 'Religion'},\n", " {'id': 'Mughal Empire',\n", " 'description': 'Empire that began in 1526, known for its architecture and relative peace.',\n", " 'type': 'Empire'},\n", " {'id': 'Indian Republic',\n", " 'description': 'India has been a federal republic since 1950.',\n", " 'type': 'Government'},\n", " {'id': 'Thailand',\n", " 'description': \"Shares maritime borders with India's Andaman and Nicobar Islands.\",\n", " 'type': 'Country'},\n", " {'id': 'Indonesia',\n", " 'description': \"Shares maritime borders with India's Andaman and Nicobar Islands.\",\n", " 'type': 'Country'},\n", " {'id': 'Andaman And Nicobar Islands',\n", " 'description': 'Islands of India sharing a maritime border with Thailand, Myanmar, and Indonesia.',\n", " 'type': 'Island'}],\n", " 'rels': [{'start': 'India',\n", " 'description': None,\n", " 'type': 'IS_PART_OF',\n", " 'end': 'Indomalayan Realm'},\n", " {'start': 'India',\n", " 'description': 'About 1,900 public sector companies with complete control and ownership of railways, highways, and majority control in various industries.',\n", " 'type': 'HAS',\n", " 'end': 'Public_Sector'},\n", " {'start': 'India',\n", " 'description': \"One of the world's highest number of billionaires.\",\n", " 'type': 'HAS',\n", " 'end': 'Billionaires'},\n", " {'start': 'India',\n", " 'description': \"World's second-largest labour force with 586 million workers.\",\n", " 'type': 'HAS',\n", " 'end': 'Labour_Force'},\n", " {'start': 'India',\n", " 'description': 'Has free trade agreements with several nations and blocs.',\n", " 'type': 'HAS',\n", " 'end': 'Free_Trade_Agreements'},\n", " {'start': 'India',\n", " 'description': \"Bombay Stock Exchange and National Stock Exchange are among the world's largest stock exchanges.\",\n", " 'type': 'HAS',\n", " 'end': 'Stock_Exchanges'},\n", " {'start': 'India',\n", " 'description': \"Nearly 65% of India's population is rural.\",\n", " 'type': 'HAS',\n", " 'end': 'Population'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'RELATES_TO',\n", " 'end': 'Rigveda'},\n", " {'start': 'India',\n", " 'description': 'Member of the World Trade Organization since 1 January 1995.',\n", " 'type': 'MEMBER_OF',\n", " 'end': 'Wto'},\n", " {'start': 'India',\n", " 'description': 'High unemployment and rising income inequality.',\n", " 'type': 'FACES',\n", " 'end': 'Unemployment'},\n", " {'start': 'India',\n", " 'description': 'Adopted broad economic liberalisation in 1991.',\n", " 'type': 'ADOPTED',\n", " 'end': 'Economic_Liberalisation'},\n", " {'start': 'India',\n", " 'description': 'Often considered a welfare state.',\n", " 'type': 'CONSIDERED_AS',\n", " 'end': 'Welfare_State'},\n", " {'start': 'India', 'description': None, 'type': 'NEAR', 'end': 'Sri Lanka'},\n", " {'start': 'India', 'description': None, 'type': 'NEAR', 'end': 'Maldives'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Indian Ocean'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Myanmar'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Himalayan Mountain Range'},\n", " {'start': 'India', 'description': None, 'type': 'BORDERS', 'end': 'China'},\n", " {'start': 'India', 'description': None, 'type': 'BORDERS', 'end': 'Bhutan'},\n", " {'start': 'India', 'description': None, 'type': 'BORDERS', 'end': 'Nepal'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Pakistan'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Bangladesh'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Arabian Sea'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'BORDERS',\n", " 'end': 'Bay Of Bengal'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'SEPARATED_BY',\n", " 'end': 'Sri Lanka'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'DERIVED_FROM',\n", " 'end': 'Sindhu'},\n", " {'start': 'India',\n", " 'description': \"Estimates India's forest cover.\",\n", " 'type': 'ESTIMATES',\n", " 'end': 'Food And Agriculture Organization Of The United Nations'},\n", " {'start': 'India',\n", " 'description': 'Makes up more than 50% of GDP.',\n", " 'type': 'MAKES_UP',\n", " 'end': 'Service_Sector'},\n", " {'start': 'India',\n", " 'description': 'Fifth-largest economy by nominal GDP and third-largest by purchasing power parity (PPP).',\n", " 'type': 'RANKS_AS',\n", " 'end': 'World'},\n", " {'start': 'India',\n", " 'description': 'Fourth-largest consumer market in the world.',\n", " 'type': 'RANKS_AS',\n", " 'end': 'Consumer_Market'},\n", " {'start': 'India',\n", " 'description': \"World's sixth-largest manufacturer, representing 2.6% of global manufacturing output.\",\n", " 'type': 'RANKS_AS',\n", " 'end': 'Manufacturing'},\n", " {'start': 'India',\n", " 'description': 'Officially declared a socialist state as per the constitution.',\n", " 'type': 'DECLARED_AS',\n", " 'end': 'Socialist_State'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'ORIGIN_OF',\n", " 'end': 'Hinduism'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'ORIGIN_OF',\n", " 'end': 'Buddhism'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'ORIGIN_OF',\n", " 'end': 'Jainism'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'GOVERNED_AS',\n", " 'end': 'Indian Republic'},\n", " {'start': 'India',\n", " 'description': '136th by GDP (nominal) and 125th by GDP (PPP) on a per capita income basis.',\n", " 'type': 'RANKS',\n", " 'end': 'Gdp'},\n", " {'start': 'India',\n", " 'description': '63rd on the Ease of Doing Business index.',\n", " 'type': 'RANKS',\n", " 'end': 'Ease_Of_Business_Index'},\n", " {'start': 'India',\n", " 'description': '40th on the Global Competitiveness Index.',\n", " 'type': 'RANKS',\n", " 'end': 'Global_Competitiveness_Index'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'SHARES_BORDERS_WITH',\n", " 'end': 'Myanmar'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'SHARES_BORDERS_WITH',\n", " 'end': 'Thailand'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'SHARES_BORDERS_WITH',\n", " 'end': 'Indonesia'},\n", " {'start': 'India',\n", " 'description': 'Overall social welfare spending stood at 8.6% of GDP in 2021-22.',\n", " 'type': 'SPENDING',\n", " 'end': 'Social_Welfare_Spending'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HISTORICAL_EVENT',\n", " 'end': 'Mughal Empire'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'ORIGINATES_IN',\n", " 'end': 'Ganges'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HAS_BIODIVERSITY_HOTSPOT',\n", " 'end': 'Western Ghats'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HAS_BIODIVERSITY_HOTSPOT',\n", " 'end': 'Eastern Himalayas'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HAS_BIODIVERSITY_HOTSPOT',\n", " 'end': 'Indo-Burma Hotspot'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HAS_ECOSYSTEM',\n", " 'end': 'Forests'},\n", " {'start': 'India',\n", " 'description': '6% to 7% since the start of the 21st century.',\n", " 'type': 'AVERAGE_ANNUAL_GROWTH',\n", " 'end': 'Gdp_Growth'},\n", " {'start': 'India',\n", " 'description': 'Foreign direct investment in 2021-22 was $82 billion.',\n", " 'type': 'FOREIGN_DIRECT_INVESTMENT',\n", " 'end': 'Fdi'},\n", " {'start': 'India',\n", " 'description': 'Gross domestic savings rate stood at 29.3% of GDP in 2022.',\n", " 'type': 'GROSS_DOMESTIC_SAVINGS_RATE',\n", " 'end': 'Savings_Rate'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HUMAN_ORIGIN',\n", " 'end': 'Africa'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'HISTORICAL_DEVELOPMENT',\n", " 'end': 'Indus Valley Civilisation'},\n", " {'start': 'India',\n", " 'description': None,\n", " 'type': 'LANGUAGE_DIFFUSION',\n", " 'end': 'Sanskrit'},\n", " {'start': 'Kautalyas Arthashastra',\n", " 'description': 'Discusses the need for forest administration.',\n", " 'type': 'DISCUSSES',\n", " 'end': 'India'},\n", " {'start': 'Indian Forest Act Of 1865',\n", " 'description': \"Establishes government's claims over forests.\",\n", " 'type': 'ESTABLISHES',\n", " 'end': 'India'},\n", " {'start': 'Crown Land (Encroachment) Ordinance',\n", " 'description': \"Targets forests in Britain's Asian colonies.\",\n", " 'type': 'TARGETS',\n", " 'end': 'India'},\n", " {'start': 'Yajnavalkya Smriti',\n", " 'description': 'Prohibits the cutting of trees.',\n", " 'type': 'PROHIBITS',\n", " 'end': 'India'},\n", " {'start': '2013 Forest Survey Of India',\n", " 'description': 'Reports on forest cover increase.',\n", " 'type': 'REPORTS_ON',\n", " 'end': 'India'},\n", " {'start': 'Supreme Court Of India',\n", " 'description': None,\n", " 'type': 'PART_OF_JUDICIARY',\n", " 'end': 'India'},\n", " {'start': 'Indian National Congress',\n", " 'description': None,\n", " 'type': 'HISTORICALLY_DOMINANT_PARTY',\n", " 'end': 'India'},\n", " {'start': 'Forest Act Of 1878',\n", " 'description': 'Gives control over all wastelands, including forests.',\n", " 'type': 'GIVES_CONTROL',\n", " 'end': 'India'},\n", " {'start': 'Sir Dietrich Brandis',\n", " 'description': 'Inspector General of Forests in India from 1864 to 1883.',\n", " 'type': 'INSPECTOR_GENERAL_OF',\n", " 'end': 'India'},\n", " {'start': 'Andaman And Nicobar Islands',\n", " 'description': None,\n", " 'type': 'MARITIME_BORDER',\n", " 'end': 'Myanmar'},\n", " {'start': 'Andaman And Nicobar Islands',\n", " 'description': None,\n", " 'type': 'MARITIME_BORDER',\n", " 'end': 'Thailand'},\n", " {'start': 'Andaman And Nicobar Islands',\n", " 'description': None,\n", " 'type': 'MARITIME_BORDER',\n", " 'end': 'Indonesia'}]},\n", " {'communityId': '1-7',\n", " 'nodes': [{'id': 'Constitution Of India',\n", " 'description': 'The supreme law of India, laying down the framework for government institutions and fundamental rights.',\n", " 'type': 'Document'},\n", " {'id': 'Parliament',\n", " 'description': 'Cannot override the Constitution of India.',\n", " 'type': 'Institution'},\n", " {'id': 'Government Of India Act 1935',\n", " 'description': 'Replaced by the Constitution of India.',\n", " 'type': 'Document'},\n", " {'id': 'Constituent Assembly',\n", " 'description': 'Tasked with drafting the Constitution of India.',\n", " 'type': 'Government body'},\n", " {'id': 'M. N. Roy',\n", " 'description': 'Proposed the framework for the Constitution of India.',\n", " 'type': 'Person'},\n", " {'id': 'Republic Day',\n", " 'description': 'Celebrated on 26 January in India to honor the Constitution.',\n", " 'type': 'Event'},\n", " {'id': 'Old Parliament House',\n", " 'description': 'Preserves the original 1950 Constitution in a nitrogen-filled case.',\n", " 'type': 'Location'},\n", " {'id': 'British Government',\n", " 'description': 'Responsible for the external security of India during its dominion status.',\n", " 'type': 'Institution'},\n", " {'id': 'Indian Independence Act 1947',\n", " 'description': 'Repealed by the Constitution of India.',\n", " 'type': 'Document'},\n", " {'id': 'Articles Of The Constitution',\n", " 'description': 'Articles 5, 6, 7, 8, 9, 60, 324, 366, 367, 379, 380, 388, 391, 392, 393, and 394 came into force on 26 November 1949.',\n", " 'type': 'Document'},\n", " {'id': 'Constituent Assembly Of India',\n", " 'description': 'Adopted the Constitution of India on 26 November 1949.',\n", " 'type': 'Institution'},\n", " {'id': 'Sardar Patel',\n", " 'description': 'Convinced princely states to sign articles of integration with India.',\n", " 'type': 'Person'},\n", " {'id': 'V. P. Menon',\n", " 'description': 'Convinced princely states to sign articles of integration with India.',\n", " 'type': 'Person'}],\n", " 'rels': [{'start': 'Constitution Of India',\n", " 'description': 'The Constitution is based on the proposal suggested by M. N. Roy.',\n", " 'type': 'BASED_ON',\n", " 'end': 'M. N. Roy'},\n", " {'start': 'Constitution Of India',\n", " 'description': 'Adopted by the Constituent Assembly on 26 November 1949.',\n", " 'type': 'ADOPTED_BY',\n", " 'end': 'Constituent Assembly Of India'},\n", " {'start': 'Constitution Of India',\n", " 'description': 'The original 1950 Constitution is preserved in a nitrogen-filled case.',\n", " 'type': 'PRESERVED_IN',\n", " 'end': 'Old Parliament House'},\n", " {'start': 'Constitution Of India',\n", " 'description': 'Celebrated on 26 January.',\n", " 'type': 'CELEBRATED_ON',\n", " 'end': 'Republic Day'},\n", " {'start': 'Constitution Of India',\n", " 'description': 'Parliament cannot override the Constitution.',\n", " 'type': 'CANNOT_OVERRIDE',\n", " 'end': 'Parliament'},\n", " {'start': 'Constitution Of India',\n", " 'description': 'Certain articles came into force on 26 November 1949.',\n", " 'type': 'CAME_INTO_FORCE',\n", " 'end': 'Articles Of The Constitution'},\n", " {'start': 'Government Of India Act 1935',\n", " 'description': 'Replaced by the Constitution of India.',\n", " 'type': 'REPLACED_BY',\n", " 'end': 'Constitution Of India'},\n", " {'start': 'British Government',\n", " 'description': 'Responsible for the external security of India during its dominion status.',\n", " 'type': 'RESPONSIBLE_FOR',\n", " 'end': 'Constitution Of India'},\n", " {'start': 'Indian Independence Act 1947',\n", " 'description': 'Repealed by the Constitution of India.',\n", " 'type': 'REPEALED_BY',\n", " 'end': 'Constitution Of India'},\n", " {'start': 'Constituent Assembly',\n", " 'description': None,\n", " 'type': 'DRAFTED_BY',\n", " 'end': 'Constitution Of India'},\n", " {'start': 'Sardar Patel',\n", " 'description': 'Convinced princely states to sign articles of integration.',\n", " 'type': 'CONVINCED',\n", " 'end': 'Constituent Assembly Of India'},\n", " {'start': 'V. P. Menon',\n", " 'description': 'Convinced princely states to sign articles of integration.',\n", " 'type': 'CONVINCED',\n", " 'end': 'Constituent Assembly Of India'}]},\n", " {'communityId': '1-4',\n", " 'nodes': [{'id': 'President Of India',\n", " 'description': 'The Supreme Commander of the Indian Armed Forces.',\n", " 'type': 'Person'},\n", " {'id': 'Nda',\n", " 'description': 'A coalition of the BJP and its allies governing India since 2014.',\n", " 'type': 'Political alliance'},\n", " {'id': 'Government Of India',\n", " 'description': 'Established a system of national parks and protected areas.',\n", " 'type': 'Government'},\n", " {'id': 'Narendra Modi',\n", " 'description': 'Current Prime Minister of India since 26 May 2014.',\n", " 'type': 'Person'},\n", " {'id': 'New Delhi',\n", " 'description': 'The seat of the Government of India.',\n", " 'type': 'Location'},\n", " {'id': 'Supreme Court',\n", " 'description': 'The highest judicial forum and final court of appeal under the Constitution of India.',\n", " 'type': 'Judiciary'},\n", " {'id': 'Indian Councils Act 1909',\n", " 'description': 'Introduced elections to the Imperial Legislative Council.',\n", " 'type': 'Legislation'},\n", " {'id': 'Government Of India Act 1919',\n", " 'description': 'Expanded the Imperial Legislative Council.',\n", " 'type': 'Legislation'},\n", " {'id': 'National Parks',\n", " 'description': 'Established in 1935 and expanded to nearly 1022 by 2023.',\n", " 'type': 'Protected area'},\n", " {'id': 'Wildlife Protection Act Of 1972',\n", " 'description': 'Enacted for the protection of wildlife.',\n", " 'type': 'Legislation'},\n", " {'id': 'Project Tiger',\n", " 'description': 'Special project for the protection of critical species.',\n", " 'type': 'Conservation project'},\n", " {'id': 'Project Elephant',\n", " 'description': 'Special project for the protection of critical species.',\n", " 'type': 'Conservation project'},\n", " {'id': 'Project Dolphin',\n", " 'description': 'Special project for the protection of critical species.',\n", " 'type': 'Conservation project'},\n", " {'id': 'Rajya Sabha',\n", " 'description': 'The mostly indirectly elected upper house of Parliament.',\n", " 'type': 'Government body'},\n", " {'id': 'Lok Sabha',\n", " 'description': 'The directly elected lower house of Parliament.',\n", " 'type': 'Government body'},\n", " {'id': 'Union Council Of Ministers',\n", " 'description': 'The executive decision-making committee of the government.',\n", " 'type': 'Government body'}],\n", " 'rels': [{'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'INITIATED',\n", " 'end': 'Project Tiger'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'INITIATED',\n", " 'end': 'Project Elephant'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'INITIATED',\n", " 'end': 'Project Dolphin'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'GOVERNED_BY',\n", " 'end': 'Nda'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'COMPOSED_OF',\n", " 'end': 'Union Council Of Ministers'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'ENACTED',\n", " 'end': 'Wildlife Protection Act Of 1972'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'ESTABLISHED',\n", " 'end': 'National Parks'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'LEAD_BY',\n", " 'end': 'Narendra Modi'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'RESPONSIBLE_TO',\n", " 'end': 'Supreme Court'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'SEATED_IN',\n", " 'end': 'New Delhi'},\n", " {'start': 'Government Of India',\n", " 'description': None,\n", " 'type': 'HEAD_OF_STATE',\n", " 'end': 'President Of India'},\n", " {'start': 'Indian Councils Act 1909',\n", " 'description': None,\n", " 'type': 'INFLUENCED',\n", " 'end': 'Government Of India'},\n", " {'start': 'Government Of India Act 1919',\n", " 'description': None,\n", " 'type': 'INFLUENCED',\n", " 'end': 'Government Of India'},\n", " {'start': 'Union Council Of Ministers',\n", " 'description': None,\n", " 'type': 'RESPONSIBLE_TO',\n", " 'end': 'Rajya Sabha'},\n", " {'start': 'Union Council Of Ministers',\n", " 'description': None,\n", " 'type': 'RESPONSIBLE_TO',\n", " 'end': 'Lok Sabha'}]},\n", " {'communityId': '1-22',\n", " 'nodes': [{'id': 'Prime Minister Of India',\n", " 'description': 'Holds executive authority and responsibility for national security.',\n", " 'type': 'Person'},\n", " {'id': 'Indian Armed Forces',\n", " 'description': 'The military forces of the Republic of India.',\n", " 'type': 'Organization'},\n", " {'id': 'Indian Army',\n", " 'description': 'One of the three professional uniformed services of the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Indian Navy',\n", " 'description': 'One of the three professional uniformed services of the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Indian Air Force',\n", " 'description': 'One of the three professional uniformed services of the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Central Armed Police Forces',\n", " 'description': 'Supports the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Indian Coast Guard',\n", " 'description': 'Supports the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Special Frontier Force',\n", " 'description': 'Supports the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Strategic Forces Command',\n", " 'description': 'An inter-service command of the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Andaman And Nicobar Command',\n", " 'description': 'An inter-service command of the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Integrated Defence Staff',\n", " 'description': 'An inter-service command of the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Ministry Of Defence',\n", " 'description': 'Manages the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Global Firepower Index',\n", " 'description': 'Ranks the military forces globally.',\n", " 'type': 'Report'},\n", " {'id': 'Armed Forces Flag Day',\n", " 'description': 'Honors armed forces and military personnel annually.',\n", " 'type': 'Event'},\n", " {'id': 'Mauryan Empire',\n", " 'description': 'An ancient Indian empire known for its powerful military.',\n", " 'type': 'Empire'},\n", " {'id': 'Chola Empire',\n", " 'description': 'Known for foreign trade and maritime activity.',\n", " 'type': 'Empire'},\n", " {'id': 'Department Of Defence Production',\n", " 'description': 'Responsible for indigenous production of equipment for the Indian Armed Forces.',\n", " 'type': 'Organization'},\n", " {'id': 'Make In India Initiative',\n", " 'description': 'Seeks to indigenise manufacturing and reduce dependence on imports for defence.',\n", " 'type': 'Program'}],\n", " 'rels': [{'start': 'Prime Minister Of India',\n", " 'description': None,\n", " 'type': 'EXECUTIVE_AUTHORITY',\n", " 'end': 'Indian Armed Forces'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Indian Army'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Indian Navy'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Indian Air Force'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'SUPPORTED_BY',\n", " 'end': 'Central Armed Police Forces'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'SUPPORTED_BY',\n", " 'end': 'Indian Coast Guard'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'SUPPORTED_BY',\n", " 'end': 'Special Frontier Force'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'SUPPORTED_BY',\n", " 'end': 'Strategic Forces Command'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'SUPPORTED_BY',\n", " 'end': 'Andaman And Nicobar Command'},\n", " {'start': 'Indian Armed Forces',\n", " 'description': None,\n", " 'type': 'SUPPORTED_BY',\n", " 'end': 'Integrated Defence Staff'},\n", " {'start': 'Ministry Of Defence',\n", " 'description': None,\n", " 'type': 'MANAGES',\n", " 'end': 'Indian Armed Forces'},\n", " {'start': 'Global Firepower Index',\n", " 'description': None,\n", " 'type': 'RANKS',\n", " 'end': 'Indian Armed Forces'},\n", " {'start': 'Armed Forces Flag Day',\n", " 'description': None,\n", " 'type': 'HONORS',\n", " 'end': 'Indian Armed Forces'},\n", " {'start': 'Department Of Defence Production',\n", " 'description': None,\n", " 'type': 'PRODUCES_EQUIPMENT_FOR',\n", " 'end': 'Indian Armed Forces'},\n", " {'start': 'Mauryan Empire',\n", " 'description': None,\n", " 'type': 'HISTORICAL_REFERENCE',\n", " 'end': 'Indian Armed Forces'},\n", " {'start': 'Chola Empire',\n", " 'description': None,\n", " 'type': 'HISTORICAL_REFERENCE',\n", " 'end': 'Indian Armed Forces'},\n", " {'start': 'Make In India Initiative',\n", " 'description': None,\n", " 'type': 'SUPPORTS',\n", " 'end': 'Department Of Defence Production'}]},\n", " {'communityId': '1-2',\n", " 'nodes': [{'id': 'Republic Of India',\n", " 'description': 'Has two principal official short names, India and Bharat.',\n", " 'type': 'Country'},\n", " {'id': 'Hindustan',\n", " 'description': 'Commonly used name for the Republic of India.',\n", " 'type': 'Name'},\n", " {'id': 'Bharat',\n", " 'description': 'Another principal official short name of the Republic of India.',\n", " 'type': 'Name'},\n", " {'id': 'Dushyanta',\n", " 'description': 'Father of Bharata, associated with the name Bhāratavarṣa.',\n", " 'type': 'Person'},\n", " {'id': 'Mahabharata',\n", " 'description': 'Epic associated with the name Bharata.',\n", " 'type': 'Literature'},\n", " {'id': 'Bhāratavarṣa',\n", " 'description': 'Term used in the first century AD, derived from the name of the Vedic community of Bharatas.',\n", " 'type': 'Historical term'},\n", " {'id': 'Bharatas',\n", " 'description': 'Mentioned in the Rigveda as one of the principal kingdoms of the Aryavarta.',\n", " 'type': 'Vedic community'}],\n", " 'rels': [{'start': 'Republic Of India',\n", " 'description': None,\n", " 'type': 'HAS_NAME',\n", " 'end': 'Bharat'},\n", " {'start': 'Republic Of India',\n", " 'description': None,\n", " 'type': 'HAS_NAME',\n", " 'end': 'Hindustan'},\n", " {'start': 'Bharat',\n", " 'description': None,\n", " 'type': 'ASSOCIATED_WITH',\n", " 'end': 'Dushyanta'},\n", " {'start': 'Bharat',\n", " 'description': None,\n", " 'type': 'ASSOCIATED_WITH',\n", " 'end': 'Mahabharata'},\n", " {'start': 'Bharat',\n", " 'description': None,\n", " 'type': 'DERIVED_FROM',\n", " 'end': 'Bhāratavarṣa'},\n", " {'start': 'Bhāratavarṣa',\n", " 'description': None,\n", " 'type': 'DERIVED_FROM',\n", " 'end': 'Bharatas'}]},\n", " {'communityId': '1-18',\n", " 'nodes': [{'id': 'Fauna Species',\n", " 'description': 'India has an estimated 92,873 species of fauna.',\n", " 'type': 'Fauna'},\n", " {'id': 'Insects',\n", " 'description': 'Major category with 63,423 recorded species.',\n", " 'type': 'Fauna'},\n", " {'id': 'Mammals Count',\n", " 'description': '423 mammals in India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Birds Count',\n", " 'description': '1,233 birds in India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Reptiles Count',\n", " 'description': '526 reptiles in India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Amphibians Count',\n", " 'description': '342 amphibians in India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Fish Count',\n", " 'description': '3,022 fish in India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Endemic Mammals',\n", " 'description': '12.6% of mammals are endemic to India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Endemic Birds',\n", " 'description': '4.5% of birds are endemic to India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Endemic Reptiles',\n", " 'description': '45.8% of reptiles are endemic to India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Endemic Amphibians',\n", " 'description': '55.8% of amphibians are endemic to India.',\n", " 'type': 'Fauna'},\n", " {'id': 'Large Animals',\n", " 'description': 'Includes Indian elephant, Indian rhinoceros, and Gaur.',\n", " 'type': 'Fauna'},\n", " {'id': 'Big Cats',\n", " 'description': 'Includes tiger and lion.',\n", " 'type': 'Fauna'},\n", " {'id': 'Cat Family',\n", " 'description': 'Includes Bengal tiger, Asiatic lion, Indian leopard, snow leopard, and clouded leopard.',\n", " 'type': 'Fauna'},\n", " {'id': 'Representative Species',\n", " 'description': 'Includes blackbuck, nilgai, bharal, barasingha, Nilgiri tahr, and Nilgiri langur.',\n", " 'type': 'Fauna'},\n", " {'id': 'Aquatic Mammals',\n", " 'description': 'Includes dolphins, whales, porpoises, and dugong.',\n", " 'type': 'Fauna'},\n", " {'id': 'Reptiles Species',\n", " 'description': 'Includes gharial and saltwater crocodiles.',\n", " 'type': 'Fauna'},\n", " {'id': 'Birds Species',\n", " 'description': 'Includes peafowl, pheasants, geese, ducks, mynas, parakeets, pigeons, cranes, hornbills, and sunbirds.',\n", " 'type': 'Fauna'},\n", " {'id': 'Endemic Bird Species',\n", " 'description': 'Includes great Indian hornbill, great Indian bustard, nicobar pigeon, ruddy shelduck, Himalayan monal, and Himalayan quail.',\n", " 'type': 'Fauna'}],\n", " 'rels': [{'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Insects'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Mammals Count'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Birds Count'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Reptiles Count'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Amphibians Count'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Fish Count'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Endemic Mammals'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Endemic Birds'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Endemic Reptiles'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Endemic Amphibians'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Large Animals'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Big Cats'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Cat Family'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Representative Species'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Aquatic Mammals'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Reptiles Species'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Birds Species'},\n", " {'start': 'Fauna Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Endemic Bird Species'}]},\n", " {'communityId': '1-20',\n", " 'nodes': [{'id': 'Plant Species',\n", " 'description': 'About 29,015 species of plants.',\n", " 'type': 'Flora'},\n", " {'id': 'Flowering Plants Count',\n", " 'description': '17,926 species of flowering plants.',\n", " 'type': 'Flora'},\n", " {'id': 'Endemic Plant Species',\n", " 'description': '6,842 species are endemic to India.',\n", " 'type': 'Flora'},\n", " {'id': 'Algae', 'description': '7,244 species.', 'type': 'Flora'},\n", " {'id': 'Bryophytes', 'description': '2,504 species.', 'type': 'Flora'},\n", " {'id': 'Pteridophytes', 'description': '1,267 species.', 'type': 'Flora'},\n", " {'id': 'Gymnosperms', 'description': '74 species.', 'type': 'Flora'},\n", " {'id': 'Fungal Diversity',\n", " 'description': 'Over 27,000 recorded species.',\n", " 'type': 'Flora'},\n", " {'id': 'Flora', 'description': None, 'type': None}],\n", " 'rels': [{'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Plant Species'},\n", " {'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Flowering Plants Count'},\n", " {'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Endemic Plant Species'},\n", " {'start': 'Flora', 'description': None, 'type': 'INCLUDES', 'end': 'Algae'},\n", " {'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Bryophytes'},\n", " {'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Pteridophytes'},\n", " {'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Gymnosperms'},\n", " {'start': 'Flora',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Fungal Diversity'}]},\n", " {'communityId': '1-19',\n", " 'nodes': [{'id': 'Threatened Species',\n", " 'description': '172 IUCN-designated threatened species.',\n", " 'type': 'Fauna'},\n", " {'id': 'Threatened Mammals',\n", " 'description': '39 species of mammals.',\n", " 'type': 'Fauna'},\n", " {'id': 'Threatened Birds',\n", " 'description': '72 species of birds.',\n", " 'type': 'Fauna'},\n", " {'id': 'Threatened Reptiles',\n", " 'description': '17 species of reptiles.',\n", " 'type': 'Fauna'},\n", " {'id': 'Threatened Amphibians',\n", " 'description': '3 species of amphibians.',\n", " 'type': 'Fauna'},\n", " {'id': 'Threatened Fish',\n", " 'description': '2 species of fish.',\n", " 'type': 'Fauna'}],\n", " 'rels': [{'start': 'Threatened Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Threatened Mammals'},\n", " {'start': 'Threatened Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Threatened Birds'},\n", " {'start': 'Threatened Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Threatened Reptiles'},\n", " {'start': 'Threatened Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Threatened Amphibians'},\n", " {'start': 'Threatened Species',\n", " 'description': None,\n", " 'type': 'INCLUDES',\n", " 'end': 'Threatened Fish'}]},\n", " {'communityId': '1-25',\n", " 'nodes': [{'id': 'Maurya Empire',\n", " 'description': 'Ancient empire based in the Ganges Basin.',\n", " 'type': 'Empire'},\n", " {'id': 'Gupta Empire',\n", " 'description': 'Ancient empire based in the Ganges Basin.',\n", " 'type': 'Empire'},\n", " {'id': 'Ganges Basin', 'description': None, 'type': None}],\n", " 'rels': [{'start': 'Ganges Basin',\n", " 'description': None,\n", " 'type': 'BASED_IN',\n", " 'end': 'Maurya Empire'},\n", " {'start': 'Ganges Basin',\n", " 'description': None,\n", " 'type': 'BASED_IN',\n", " 'end': 'Gupta Empire'}]},\n", " {'communityId': '1-26',\n", " 'nodes': [{'id': 'Vijayanagara Empire',\n", " 'description': 'Empire in south India that created a composite Hindu culture.',\n", " 'type': 'Empire'},\n", " {'id': 'South India', 'description': None, 'type': None}],\n", " 'rels': [{'start': 'South India',\n", " 'description': None,\n", " 'type': 'BASED_IN',\n", " 'end': 'Vijayanagara Empire'}]},\n", " {'communityId': '1-27',\n", " 'nodes': [{'id': 'Sikhism',\n", " 'description': 'Religion that emerged in the Punjab, rejecting institutionalised religion.',\n", " 'type': 'Religion'},\n", " {'id': 'Punjab', 'description': None, 'type': None}],\n", " 'rels': [{'start': 'Punjab',\n", " 'description': None,\n", " 'type': 'ORIGIN_OF',\n", " 'end': 'Sikhism'}]},\n", " {'communityId': '1-24',\n", " 'nodes': [{'id': 'British East India Company',\n", " 'description': 'Company that expanded rule in India, turning it into a colonial economy.',\n", " 'type': 'Company'},\n", " {'id': 'British Crown',\n", " 'description': 'Began rule in India in 1858.',\n", " 'type': 'Government'},\n", " {'id': 'Indian Independence',\n", " 'description': 'Event in 1947 when India was partitioned into two independent dominions.',\n", " 'type': 'Event'}],\n", " 'rels': [{'start': 'British East India Company',\n", " 'description': None,\n", " 'type': 'HISTORICAL_EVENT',\n", " 'end': 'British Crown'},\n", " {'start': 'British Crown',\n", " 'description': None,\n", " 'type': 'HISTORICAL_EVENT',\n", " 'end': 'Indian Independence'}]}]" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "community_info" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "community_template = \"\"\"Based on the provided nodes and relationships that belong to the same graph community,\n", "generate a natural language summary of the provided information:\n", "{community_info}\n", "\n", "Summary:\"\"\" \n", "model = \"openai-gpt-4o\"\n", "llm, model_name = get_llm(model)\n", "community_prompt = ChatPromptTemplate.from_messages(\n", " [\n", " (\n", " \"system\",\n", " \"Given an input triples, generate the information summary. No pre-amble.\",\n", " ),\n", " (\"human\", community_template),\n", " ]\n", ")\n", "\n", "community_chain = community_prompt | llm | StrOutputParser()" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "def prepare_string(data):\n", " nodes_str = \"Nodes are:\\n\"\n", " for node in data['nodes']:\n", " node_id = node['id']\n", " node_type = node['type']\n", " if 'description' in node and node['description']:\n", " node_description = f\", description: {node['description']}\"\n", " else:\n", " node_description = \"\"\n", " nodes_str += f\"id: {node_id}, type: {node_type}{node_description}\\n\"\n", "\n", " rels_str = \"Relationships are:\\n\"\n", " for rel in data['rels']:\n", " start = rel['start']\n", " end = rel['end']\n", " rel_type = rel['type']\n", " if 'description' in rel and rel['description']:\n", " description = f\", description: {rel['description']}\"\n", " else:\n", " description = \"\"\n", " rels_str += f\"({start})-[:{rel_type}]->({end}){description}\\n\"\n", "\n", " return nodes_str + \"\\n\" + rels_str\n", "\n", "def process_community(community):\n", " stringify_info = prepare_string(community)\n", " summary = community_chain.invoke({'community_info': stringify_info})\n", " return {\"community\": community['communityId'], \"summary\": summary}" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Nodes are:\n", "id: India, type: Country, description: Officially the Republic of India, located in South Asia.\n", "id: Supreme Court Of India, type: Judiciary, description: Head of the independent judiciary.\n", "id: Indian National Congress, type: Political party, description: Dominated Indian politics until 1977.\n", "id: Sindhu, type: River, description: Name of the Indus River, from which the name India is derived.\n", "id: Food And Agriculture Organization Of The United Nations, type: Organization, description: Estimates India's forest cover.\n", "id: 2013 Forest Survey Of India, type: Report, description: States India's forest cover increased to 69.8 million hectares by 2012.\n", "id: Yajnavalkya Smriti, type: Literature, description: Prohibited the cutting of trees.\n", "id: Kautalyas Arthashastra, type: Literature, description: Discusses the need for forest administration.\n", "id: Crown Land (Encroachment) Ordinance, type: Legislation, description: Promulgated in 1840 targeting forests in Britain's Asian colonies.\n", "id: Indian Forest Act Of 1865, type: Legislation, description: Established the government's claims over forests.\n", "id: Forest Act Of 1878, type: Legislation, description: Gave the British government control over all wastelands, including forests.\n", "id: Sir Dietrich Brandis, type: Person, description: Inspector General of Forests in India from 1864 to 1883.\n", "id: Indian Ocean, type: Ocean, description: Ocean bounded by India on the north.\n", "id: Sri Lanka, type: Country, description: Country in the vicinity of India in the Indian Ocean.\n", "id: Maldives, type: Country, description: Country in the vicinity of India in the Indian Ocean.\n", "id: Myanmar, type: Country, description: Country sharing land border with India to the east.\n", "id: Himalayan Mountain Range, type: Mountain range, description: Defines the northern frontiers of India.\n", "id: China, type: Country, description: Country sharing land border with India to the north.\n", "id: Bhutan, type: Country, description: Country sharing land border with India to the north.\n", "id: Nepal, type: Country, description: Country sharing land border with India to the north.\n", "id: Pakistan, type: Country, description: Country sharing land border with India to the west.\n", "id: Bangladesh, type: Country, description: Country sharing land border with India to the east.\n", "id: Ganges, type: River, description: The longest river originating in India.\n", "id: Western Ghats, type: Biodiversity hotspot, description: One of the three biodiversity hotspots in India.\n", "id: Eastern Himalayas, type: Biodiversity hotspot, description: One of the three biodiversity hotspots in India.\n", "id: Indo-Burma Hotspot, type: Biodiversity hotspot, description: One of the three biodiversity hotspots in India.\n", "id: Forests, type: Ecosystem, description: Covers about 24.6% of the total land area.\n", "id: Indomalayan Realm, type: Realm, description: Geographical realm that includes India.\n", "id: World, type: None\n", "id: Public_Sector, type: None\n", "id: Gdp, type: None\n", "id: Economic_Liberalisation, type: None\n", "id: Gdp_Growth, type: None\n", "id: Consumer_Market, type: None\n", "id: Wto, type: None\n", "id: Ease_Of_Business_Index, type: None\n", "id: Global_Competitiveness_Index, type: None\n", "id: Billionaires, type: None\n", "id: Welfare_State, type: None\n", "id: Socialist_State, type: None\n", "id: Social_Welfare_Spending, type: None\n", "id: Labour_Force, type: None\n", "id: Fdi, type: None\n", "id: Free_Trade_Agreements, type: None\n", "id: Service_Sector, type: None\n", "id: Stock_Exchanges, type: None\n", "id: Manufacturing, type: None\n", "id: Population, type: None\n", "id: Unemployment, type: None\n", "id: Savings_Rate, type: None\n", "id: Arabian Sea, type: Sea, description: Sea bounded by India on the northwest.\n", "id: Bay Of Bengal, type: Bay, description: Bay bounded by India on the southeast.\n", "id: Africa, type: Continent, description: Continent from which modern humans arrived on the Indian subcontinent.\n", "id: Indus Valley Civilisation, type: Civilization, description: Civilisation that evolved from settled life in the western margins of the Indus river basin.\n", "id: Sanskrit, type: Language, description: Indo-European language that diffused into India from the northwest.\n", "id: Rigveda, type: Text, description: Ancient hymns recording the dawning of Hinduism in India.\n", "id: Hinduism, type: Religion, description: Major religion in India, with roots in the Rigveda.\n", "id: Buddhism, type: Religion, description: Religion that arose in India, proclaiming social orders unlinked to heredity.\n", "id: Jainism, type: Religion, description: Religion that arose in India, proclaiming social orders unlinked to heredity.\n", "id: Mughal Empire, type: Empire, description: Empire that began in 1526, known for its architecture and relative peace.\n", "id: Indian Republic, type: Government, description: India has been a federal republic since 1950.\n", "\n", "Relationships are:\n", "(India)-[:IS_PART_OF]->(Indomalayan Realm)\n", "(India)-[:HAS]->(Public_Sector), description: About 1,900 public sector companies with complete control and ownership of railways, highways, and majority control in various industries.\n", "(India)-[:HAS]->(Billionaires), description: One of the world's highest number of billionaires.\n", "(India)-[:HAS]->(Labour_Force), description: World's second-largest labour force with 586 million workers.\n", "(India)-[:HAS]->(Free_Trade_Agreements), description: Has free trade agreements with several nations and blocs.\n", "(India)-[:HAS]->(Stock_Exchanges), description: Bombay Stock Exchange and National Stock Exchange are among the world's largest stock exchanges.\n", "(India)-[:HAS]->(Population), description: Nearly 65% of India's population is rural.\n", "(India)-[:RELATES_TO]->(Rigveda)\n", "(India)-[:MEMBER_OF]->(Wto), description: Member of the World Trade Organization since 1 January 1995.\n", "(India)-[:FACES]->(Unemployment), description: High unemployment and rising income inequality.\n", "(India)-[:ADOPTED]->(Economic_Liberalisation), description: Adopted broad economic liberalisation in 1991.\n", "(India)-[:CONSIDERED_AS]->(Welfare_State), description: Often considered a welfare state.\n", "(India)-[:NEAR]->(Sri Lanka)\n", "(India)-[:NEAR]->(Maldives)\n", "(India)-[:BORDERS]->(Indian Ocean)\n", "(India)-[:BORDERS]->(Myanmar)\n", "(India)-[:BORDERS]->(Himalayan Mountain Range)\n", "(India)-[:BORDERS]->(China)\n", "(India)-[:BORDERS]->(Bhutan)\n", "(India)-[:BORDERS]->(Nepal)\n", "(India)-[:BORDERS]->(Pakistan)\n", "(India)-[:BORDERS]->(Bangladesh)\n", "(India)-[:BORDERS]->(Arabian Sea)\n", "(India)-[:BORDERS]->(Bay Of Bengal)\n", "(India)-[:SEPARATED_BY]->(Sri Lanka)\n", "(India)-[:DERIVED_FROM]->(Sindhu)\n", "(India)-[:ESTIMATES]->(Food And Agriculture Organization Of The United Nations), description: Estimates India's forest cover.\n", "(India)-[:MAKES_UP]->(Service_Sector), description: Makes up more than 50% of GDP.\n", "(India)-[:RANKS_AS]->(World), description: Fifth-largest economy by nominal GDP and third-largest by purchasing power parity (PPP).\n", "(India)-[:RANKS_AS]->(Consumer_Market), description: Fourth-largest consumer market in the world.\n", "(India)-[:RANKS_AS]->(Manufacturing), description: World's sixth-largest manufacturer, representing 2.6% of global manufacturing output.\n", "(India)-[:DECLARED_AS]->(Socialist_State), description: Officially declared a socialist state as per the constitution.\n", "(India)-[:ORIGIN_OF]->(Hinduism)\n", "(India)-[:ORIGIN_OF]->(Buddhism)\n", "(India)-[:ORIGIN_OF]->(Jainism)\n", "(India)-[:GOVERNED_AS]->(Indian Republic)\n", "(India)-[:RANKS]->(Gdp), description: 136th by GDP (nominal) and 125th by GDP (PPP) on a per capita income basis.\n", "(India)-[:RANKS]->(Ease_Of_Business_Index), description: 63rd on the Ease of Doing Business index.\n", "(India)-[:RANKS]->(Global_Competitiveness_Index), description: 40th on the Global Competitiveness Index.\n", "(India)-[:SHARES_BORDERS_WITH]->(Myanmar)\n", "(India)-[:SPENDING]->(Social_Welfare_Spending), description: Overall social welfare spending stood at 8.6% of GDP in 2021-22.\n", "(India)-[:HISTORICAL_EVENT]->(Mughal Empire)\n", "(India)-[:ORIGINATES_IN]->(Ganges)\n", "(India)-[:HAS_BIODIVERSITY_HOTSPOT]->(Western Ghats)\n", "(India)-[:HAS_BIODIVERSITY_HOTSPOT]->(Eastern Himalayas)\n", "(India)-[:HAS_BIODIVERSITY_HOTSPOT]->(Indo-Burma Hotspot)\n", "(India)-[:HAS_ECOSYSTEM]->(Forests)\n", "(India)-[:AVERAGE_ANNUAL_GROWTH]->(Gdp_Growth), description: 6% to 7% since the start of the 21st century.\n", "(India)-[:FOREIGN_DIRECT_INVESTMENT]->(Fdi), description: Foreign direct investment in 2021-22 was $82 billion.\n", "(India)-[:GROSS_DOMESTIC_SAVINGS_RATE]->(Savings_Rate), description: Gross domestic savings rate stood at 29.3% of GDP in 2022.\n", "(India)-[:HUMAN_ORIGIN]->(Africa)\n", "(India)-[:HISTORICAL_DEVELOPMENT]->(Indus Valley Civilisation)\n", "(India)-[:LANGUAGE_DIFFUSION]->(Sanskrit)\n", "(Kautalyas Arthashastra)-[:DISCUSSES]->(India), description: Discusses the need for forest administration.\n", "(Indian Forest Act Of 1865)-[:ESTABLISHES]->(India), description: Establishes government's claims over forests.\n", "(Crown Land (Encroachment) Ordinance)-[:TARGETS]->(India), description: Targets forests in Britain's Asian colonies.\n", "(Yajnavalkya Smriti)-[:PROHIBITS]->(India), description: Prohibits the cutting of trees.\n", "(2013 Forest Survey Of India)-[:REPORTS_ON]->(India), description: Reports on forest cover increase.\n", "(Supreme Court Of India)-[:PART_OF_JUDICIARY]->(India)\n", "(Indian National Congress)-[:HISTORICALLY_DOMINANT_PARTY]->(India)\n", "(Forest Act Of 1878)-[:GIVES_CONTROL]->(India), description: Gives control over all wastelands, including forests.\n", "(Sir Dietrich Brandis)-[:INSPECTOR_GENERAL_OF]->(India), description: Inspector General of Forests in India from 1864 to 1883.\n", "\n" ] } ], "source": [ "print(prepare_string(community_info[0]))" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Processing communities: 0%| | 0/30 [00:00 pd.DataFrame:\n", " \"\"\"Executes a Cypher statement and returns a DataFrame\"\"\"\n", " return driver.execute_query(\n", " cypher, parameters_=params, result_transformer_=Result.to_df\n", " )" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "## Calculate before \n", "db_query(\n", " \"\"\"\n", "MATCH (n:`__Community__`)<-[:IN_COMMUNITY]-()<-[:HAS_ENTITY]-(c)\n", "WITH n, count(distinct c) AS chunkCount\n", "SET n.weight = chunkCount\"\"\"\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## local and global search" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "index_name = \"entity_local\"\n", "\n", "# db_query(\n", "# \"\"\"\n", "# CREATE VECTOR INDEX \"\"\"\n", "# + index_name\n", "# + \"\"\" IF NOT EXISTS FOR (e:__Entity__) ON e.embedding\n", "# OPTIONS {indexConfig: {\n", "# `vector.dimensions`: 384,\n", "# `vector.similarity_function`: 'cosine'\n", "# }}\n", "# \"\"\"\n", "# )" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "topChunks = 3\n", "topCommunities = 3\n", "topOutsideRels = 10\n", "topInsideRels = 10\n", "topEntities = 10" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "lc_retrieval_query = \"\"\"\n", "WITH collect(node) as nodes\n", "// Entity - Text Unit Mapping\n", "WITH\n", "collect {\n", " UNWIND nodes as n\n", " MATCH (n)<-[:HAS_ENTITY]->(c:Chunk)\n", " WITH c, count(distinct n) as freq\n", " RETURN c.text AS chunkText\n", " ORDER BY freq DESC\n", " LIMIT $topChunks\n", "} AS text_mapping,\n", "// Entity - Report Mapping\n", "collect {\n", " UNWIND nodes as n\n", " MATCH (n)-[:IN_COMMUNITY]->(c:__Community__)\n", " WITH c, c.rank as rank, c.weight AS weight\n", " RETURN c.summary \n", " ORDER BY rank, weight DESC\n", " LIMIT $topCommunities\n", "} AS report_mapping,\n", "// Outside Relationships \n", "collect {\n", " UNWIND nodes as n\n", " MATCH (n)-[r:RELATED]-(m) \n", " WHERE NOT m IN nodes\n", " RETURN r.description AS descriptionText\n", " ORDER BY r.rank, r.weight DESC \n", " LIMIT $topOutsideRels\n", "} as outsideRels,\n", "// Inside Relationships \n", "collect {\n", " UNWIND nodes as n\n", " MATCH (n)-[r:RELATED]-(m) \n", " WHERE m IN nodes\n", " RETURN r.description AS descriptionText\n", " ORDER BY r.rank, r.weight DESC \n", " LIMIT $topInsideRels\n", "} as insideRels,\n", "// Entities description\n", "collect {\n", " UNWIND nodes as n\n", " RETURN n.description AS descriptionText\n", "} as entities\n", "// We don't have covariates or claims here\n", "RETURN {Chunks: text_mapping, Reports: report_mapping, \n", " Relationships: outsideRels + insideRels, \n", " Entities: entities} AS text, 1.0 AS score, {} AS metadata\n", "\"\"\"\n", "\n", "embeddings, dimension = load_embedding_model(\"sentence_transformer\")\n", "lc_vector = Neo4jVector.from_existing_index(\n", " embeddings,\n", " url=os.environ[\"NEO4J_URI\"],\n", " username=os.environ[\"NEO4J_USERNAME\"],\n", " password=os.environ[\"NEO4J_PASSWORD\"],\n", " index_name=index_name,\n", " retrieval_query=lc_retrieval_query,\n", ")" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "docs = lc_vector.similarity_search_with_score(\n", " \"Major cities of India\",\n", " k=topEntities,\n", " params={\n", " \"topChunks\": topChunks,\n", " \"topCommunities\": topCommunities,\n", " \"topOutsideRels\": topOutsideRels,\n", " \"topInsideRels\": topInsideRels,\n", " },\n", ")" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Entities:\n", "- None\n", "- None\n", "- None\n", "- One of the three biodiversity hotspots in India.\n", "- Officially the Republic of India, located in South Asia.\n", "- Geographical realm that includes India.\n", "- One of the three biodiversity hotspots in India.\n", "- Defines the northern frontiers of India.\n", "- One of the three biodiversity hotspots in India.\n", "- Commonly used name for the Republic of India.\n", "Reports:\n", "- India, officially the Republic of India, is a country located in South Asia and is part of the Indomalayan Realm. It shares borders with several countries including China, Bhutan, Nepal, Pakistan, Bangladesh, and Myanmar, and is bounded by the Indian Ocean, Arabian Sea, and Bay of Bengal. India is known for its rich biodiversity, featuring hotspots like the Western Ghats, Eastern Himalayas, and Indo-Burma Hotspot, and has a significant forest cover, which has been increasing as reported by the 2013 Forest Survey of India.\n", "\n", "India has a complex history, with ancient civilizations like the Indus Valley Civilisation and significant cultural contributions such as the Rigveda, which marks the dawn of Hinduism. It is also the birthplace of Buddhism and Jainism. The country has a diverse linguistic heritage, including the diffusion of the Indo-European language Sanskrit.\n", "\n", "Economically, India is a major global player, ranking as the fifth-largest economy by nominal GDP and third-largest by purchasing power parity (PPP). It has a significant public sector, a large labor force, and is a member of the World Trade Organization. The country has adopted broad economic liberalization since 1991, leading to substantial GDP growth and a robust service sector that makes up more than 50% of its GDP. India also has a high number of billionaires and is considered a welfare state with significant social welfare spending.\n", "\n", "Politically, India has been a federal republic since 1950, with the Indian National Congress historically dominating its politics until 1977. The Supreme Court of India heads its independent judiciary. The country has a rich legislative history concerning forest administration, with significant acts like the Indian Forest Act of 1865 and the Forest Act of 1878, and contributions from figures like Sir Dietrich Brandis, the Inspector General of Forests from 1864 to 1883.\n", "\n", "India's geographical and cultural landscape is further enriched by its rivers, such as the Ganges and Sindhu (Indus River), and its proximity to neighboring countries like Sri Lanka and the Maldives. The country is also part of the larger Indomalayan Realm and has historical ties to Africa, from where modern humans arrived on the Indian subcontinent.\n", "- India, officially the Republic of India, is a country located in South Asia and is part of the Indomalayan Realm. It shares borders with several countries including China, Bhutan, Nepal, Pakistan, Bangladesh, and Myanmar, and is bounded by the Indian Ocean, Arabian Sea, and Bay of Bengal. India is known for its rich biodiversity, featuring hotspots like the Western Ghats, Eastern Himalayas, and Indo-Burma Hotspot, and has a significant forest cover, which has been increasing as reported by the 2013 Forest Survey of India.\n", "\n", "India has a complex history, with ancient civilizations like the Indus Valley Civilisation and significant cultural contributions such as the Rigveda, which marks the dawn of Hinduism. It is also the birthplace of Buddhism and Jainism. The country has a diverse linguistic heritage, including the diffusion of the Indo-European language Sanskrit.\n", "\n", "Economically, India is a major global player, ranking as the fifth-largest economy by nominal GDP and third-largest by purchasing power parity (PPP). It has a significant public sector, a large labor force, and is a member of the World Trade Organization. The country has adopted broad economic liberalization since 1991, leading to substantial GDP growth and a robust service sector that makes up more than 50% of its GDP. India also has a high number of billionaires and is considered a welfare state with significant social welfare spending.\n", "\n", "Politically, India has been a federal republic since 1950, with the Indian National Congress historically dominating its politics until 1977. The Supreme Court of India heads its independent judiciary. The country has a rich legislative history concerning forest administration, with significant acts like the Indian Forest Act of 1865 and the Forest Act of 1878, and contributions from figures like Sir Dietrich Brandis, the Inspector General of Forests from 1864 to 1883.\n", "\n", "India's geographical and cultural landscape is further enriched by its rivers, such as the Ganges and Sindhu (Indus River), and its proximity to neighboring countries like Sri Lanka and the Maldives. The country is also part of the larger Indomalayan Realm and has historical ties to Africa, from where modern humans arrived on the Indian subcontinent.\n", "- India, officially the Republic of India, is a country located in South Asia and is part of the Indomalayan Realm. It shares borders with several countries including China, Bhutan, Nepal, Pakistan, Bangladesh, and Myanmar, and is bounded by the Indian Ocean, Arabian Sea, and Bay of Bengal. India is known for its rich biodiversity, featuring hotspots like the Western Ghats, Eastern Himalayas, and Indo-Burma Hotspot, and has a significant forest cover, which has been increasing as reported by the 2013 Forest Survey of India.\n", "\n", "India has a complex history, with ancient civilizations like the Indus Valley Civilisation and significant cultural contributions such as the Rigveda, which marks the dawn of Hinduism. It is also the birthplace of Buddhism and Jainism. The country has a diverse linguistic heritage, including the diffusion of the Indo-European language Sanskrit.\n", "\n", "Economically, India is a major global player, ranking as the fifth-largest economy by nominal GDP and third-largest by purchasing power parity (PPP). It has a significant public sector, a large labor force, and is a member of the World Trade Organization. The country has adopted broad economic liberalization since 1991, leading to substantial GDP growth and a robust service sector that makes up more than 50% of its GDP. India also has a high number of billionaires and is considered a welfare state with significant social welfare spending.\n", "\n", "Politically, India has been a federal republic since 1950, with the Indian National Congress historically dominating its politics until 1977. The Supreme Court of India heads its independent judiciary. The country has a rich legislative history concerning forest administration, with significant acts like the Indian Forest Act of 1865 and the Forest Act of 1878, and contributions from figures like Sir Dietrich Brandis, the Inspector General of Forests from 1864 to 1883.\n", "\n", "India's geographical and cultural landscape is further enriched by its rivers, such as the Ganges and Sindhu (Indus River), and its proximity to neighboring countries like Sri Lanka and the Maldives. The country is also part of the larger Indomalayan Realm and has historical ties to Africa, from where modern humans arrived on the Indian subcontinent.\n", "Chunks:\n", "- India is one of the most biodiverse regions and is home to a large variety of wildlife. It is one of the 17 megadiverse countries and includes three of the worlds 36 biodiversity hotspots – the Western Ghats, the Eastern Himalayas, and the Indo-Burma hotspot. About 24.6% of the total land area is covered by forests. It has various ecosystems ranging from the high altitude Himalayas, tropical evergreen forests along the Western Ghats, desert in the north-west, coastal plains and mangroves along the peninsular region. India lies within the Indomalayan realm and is home to about 7.6% of mammal, 14.7% of amphibian, 6% of bird, 6.2% of reptilian, and 6.2% of flowering plant species. Human encroachment, deforestation and poaching are significant challenges that threaten the existence of certain fauna and flora. Government of India established a system of national parks and\n", "- threaten the existence of certain fauna and flora. Government of India established a system of national parks and protected areas in 1935, which have been subsequently expanded to nearly 1022 protected areas by 2023. India has enacted the Wildlife Protection Act of 1972 and special projects such as Project Tiger, Project Elephant and Project Dolphin for protection of critical species. == Fauna == India has an estimated 92,873 species of fauna, roughly about 7.5% of the species available worldwide. Insects form the major category with 63423 recorded species. India is home to 423 mammals, 1233 birds, 526 reptiles, 342 amphibians, 3022 fish apart from other species which form 7.6% of mammal, 14.7% of amphibian, 6% of bird, 6.2% of reptilian species worldwide. Many Indian species are descendants of species originating in Gondwana, of which India originally was a part. Peninsular Indias subsequent movement towards\n", "- Gondwana, of which India originally was a part. Peninsular Indias subsequent movement towards, and collision with, the Laurasian landmass set off a mass exchange of species. However, volcanism in the Deccan Traps and climatic change 20 million years ago caused the extinction of many endemic Indian forms. Soon thereafter, mammals entered India from Asia through two zoogeographical passes on either side of the emerging Himalayas. As a result, among Indian species, only 12.6% of mammals and 4.5% of birds are endemic, contrasting with 45.8% of reptiles and 55.8% of amphibians India is home to several well-known large animals, including the Indian elephant, Indian rhinoceros, and Gaur. India is the only country where the big cats tiger and lion exist in the wild. Members of the cat family include Bengal tiger, Asiatic lion, Indian leopard, snow leopard, and clouded\n", "Relationships:\n", "\n" ] } ], "source": [ "print(docs[0][0].page_content)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "model = \"openai-gpt-4o\"\n", "llm, model_name = get_llm(model)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "MAP_SYSTEM_PROMPT = \"\"\"\n", "---Role---\n", "\n", "You are a helpful assistant responding to questions about data in the tables provided.\n", "\n", "\n", "---Goal---\n", "\n", "Generate a response consisting of a list of key points that responds to the user's question, summarizing all relevant information in the input data tables.\n", "\n", "You should use the data provided in the data tables below as the primary context for generating the response.\n", "If you don't know the answer or if the input data tables do not contain sufficient information to provide an answer, just say so. Do not make anything up.\n", "\n", "Each key point in the response should have the following element:\n", "- Description: A comprehensive description of the point.\n", "- Importance Score: An integer score between 0-100 that indicates how important the point is in answering the user's question. An 'I don't know' type of response should have a score of 0.\n", "\n", "The response should be JSON formatted as follows:\n", "{{\n", " \"points\": [\n", " {{\"description\": \"Description of point 1 [Data: Reports (report ids)]\", \"score\": score_value}},\n", " {{\"description\": \"Description of point 2 [Data: Reports (report ids)]\", \"score\": score_value}}\n", " ]\n", "}}\n", "\n", "The response shall preserve the original meaning and use of modal verbs such as \"shall\", \"may\" or \"will\".\n", "\n", "Points supported by data should list the relevant reports as references as follows:\n", "\"This is an example sentence supported by data references [Data: Reports (report ids)]\"\n", "\n", "**Do not list more than 5 record ids in a single reference**. Instead, list the top 5 most relevant record ids and add \"+more\" to indicate that there are more.\n", "\n", "For example:\n", "\"Person X is the owner of Company Y and subject to many allegations of wrongdoing [Data: Reports (2, 7, 64, 46, 34, +more)]. He is also CEO of company X [Data: Reports (1, 3)]\"\n", "\n", "where 1, 2, 3, 7, 34, 46, and 64 represent the id (not the index) of the relevant data report in the provided tables.\n", "\n", "Do not include information where the supporting evidence for it is not provided.\n", "\n", "\n", "---Data tables---\n", "\n", "{context_data}\n", "\n", "---Goal---\n", "\n", "Generate a response consisting of a list of key points that responds to the user's question, summarizing all relevant information in the input data tables.\n", "\n", "You should use the data provided in the data tables below as the primary context for generating the response.\n", "If you don't know the answer or if the input data tables do not contain sufficient information to provide an answer, just say so. Do not make anything up.\n", "\n", "Each key point in the response should have the following element:\n", "- Description: A comprehensive description of the point.\n", "- Importance Score: An integer score between 0-100 that indicates how important the point is in answering the user's question. An 'I don't know' type of response should have a score of 0.\n", "\n", "The response shall preserve the original meaning and use of modal verbs such as \"shall\", \"may\" or \"will\".\n", "\n", "Points supported by data should list the relevant reports as references as follows:\n", "\"This is an example sentence supported by data references [Data: Reports (report ids)]\"\n", "\n", "**Do not list more than 5 record ids in a single reference**. Instead, list the top 5 most relevant record ids and add \"+more\" to indicate that there are more.\n", "\n", "For example:\n", "\"Person X is the owner of Company Y and subject to many allegations of wrongdoing [Data: Reports (2, 7, 64, 46, 34, +more)]. He is also CEO of company X [Data: Reports (1, 3)]\"\n", "\n", "where 1, 2, 3, 7, 34, 46, and 64 represent the id (not the index) of the relevant data report in the provided tables.\n", "\n", "Do not include information where the supporting evidence for it is not provided.\n", "\n", "The response should be JSON formatted as follows:\n", "{{\n", " \"points\": [\n", " {{\"description\": \"Description of point 1 [Data: Reports (report ids)]\", \"score\": score_value}},\n", " {{\"description\": \"Description of point 2 [Data: Reports (report ids)]\", \"score\": score_value}}\n", " ]\n", "}}\n", "\"\"\"\n", "\n", "map_prompt = ChatPromptTemplate.from_messages(\n", " [\n", " (\n", " \"system\",\n", " MAP_SYSTEM_PROMPT,\n", " ),\n", " (\n", " \"human\",\n", " \"{question}\",\n", " ),\n", " ]\n", ")\n", "\n", "map_chain = map_prompt | llm | StrOutputParser()" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "REDUCE_SYSTEM_PROMPT = \"\"\"\n", "---Role---\n", "\n", "You are a helpful assistant responding to questions about a dataset by synthesizing perspectives from multiple analysts.\n", "\n", "\n", "---Goal---\n", "\n", "Generate a response of the target length and format that responds to the user's question, summarize all the reports from multiple analysts who focused on different parts of the dataset.\n", "\n", "Note that the analysts' reports provided below are ranked in the **descending order of importance**.\n", "\n", "If you don't know the answer or if the provided reports do not contain sufficient information to provide an answer, just say so. Do not make anything up.\n", "\n", "The final response should remove all irrelevant information from the analysts' reports and merge the cleaned information into a comprehensive answer that provides explanations of all the key points and implications appropriate for the response length and format.\n", "\n", "Add sections and commentary to the response as appropriate for the length and format. Style the response in markdown.\n", "\n", "The response shall preserve the original meaning and use of modal verbs such as \"shall\", \"may\" or \"will\".\n", "\n", "The response should also preserve all the data references previously included in the analysts' reports, but do not mention the roles of multiple analysts in the analysis process.\n", "\n", "**Do not list more than 5 record ids in a single reference**. Instead, list the top 5 most relevant record ids and add \"+more\" to indicate that there are more.\n", "\n", "For example:\n", "\n", "\"Person X is the owner of Company Y and subject to many allegations of wrongdoing [Data: Reports (2, 7, 34, 46, 64, +more)]. He is also CEO of company X [Data: Reports (1, 3)]\"\n", "\n", "where 1, 2, 3, 7, 34, 46, and 64 represent the id (not the index) of the relevant data record.\n", "\n", "Do not include information where the supporting evidence for it is not provided.\n", "\n", "\n", "---Target response length and format---\n", "\n", "{response_type}\n", "\n", "\n", "---Analyst Reports---\n", "\n", "{report_data}\n", "\n", "\n", "---Goal---\n", "\n", "Generate a response of the target length and format that responds to the user's question, summarize all the reports from multiple analysts who focused on different parts of the dataset.\n", "\n", "Note that the analysts' reports provided below are ranked in the **descending order of importance**.\n", "\n", "If you don't know the answer or if the provided reports do not contain sufficient information to provide an answer, just say so. Do not make anything up.\n", "\n", "The final response should remove all irrelevant information from the analysts' reports and merge the cleaned information into a comprehensive answer that provides explanations of all the key points and implications appropriate for the response length and format.\n", "\n", "The response shall preserve the original meaning and use of modal verbs such as \"shall\", \"may\" or \"will\".\n", "\n", "The response should also preserve all the data references previously included in the analysts' reports, but do not mention the roles of multiple analysts in the analysis process.\n", "\n", "**Do not list more than 5 record ids in a single reference**. Instead, list the top 5 most relevant record ids and add \"+more\" to indicate that there are more.\n", "\n", "For example:\n", "\n", "\"Person X is the owner of Company Y and subject to many allegations of wrongdoing [Data: Reports (2, 7, 34, 46, 64, +more)]. He is also CEO of company X [Data: Reports (1, 3)]\"\n", "\n", "where 1, 2, 3, 7, 34, 46, and 64 represent the id (not the index) of the relevant data record.\n", "\n", "Do not include information where the supporting evidence for it is not provided.\n", "\n", "\n", "---Target response length and format---\n", "\n", "{response_type}\n", "\n", "Add sections and commentary to the response as appropriate for the length and format. Style the response in markdown.\n", "\"\"\"\n", "\n", "reduce_prompt = ChatPromptTemplate.from_messages(\n", " [\n", " (\n", " \"system\",\n", " REDUCE_SYSTEM_PROMPT,\n", " ),\n", " (\n", " \"human\",\n", " \"{question}\",\n", " ),\n", " ]\n", ")\n", "reduce_chain = reduce_prompt | llm | StrOutputParser()" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "graph = Neo4jGraph(\n", " url=os.environ[\"NEO4J_URI\"],\n", " username=os.environ[\"NEO4J_USERNAME\"],\n", " password=os.environ[\"NEO4J_PASSWORD\"],\n", " refresh_schema=False,\n", ")\n", "\n", "response_type: str = \"multiple paragraphs\"\n", "\n", "\n", "def global_retriever(query: str, level: int, response_type: str = response_type) -> str:\n", " community_data = graph.query(\n", " \"\"\"\n", " MATCH (c:__Community__)\n", " WHERE c.level = $level\n", " RETURN c.full_content AS output\n", " \"\"\",\n", " params={\"level\": level},\n", " )\n", " intermediate_results = []\n", " for community in tqdm(community_data, desc=\"Processing communities\"):\n", " intermediate_response = map_chain.invoke(\n", " {\"question\": query, \"context_data\": community[\"output\"]}\n", " )\n", " intermediate_results.append(intermediate_response)\n", " final_response = reduce_chain.invoke(\n", " {\n", " \"report_data\": intermediate_results,\n", " \"question\": query,\n", " \"response_type\": response_type,\n", " }\n", " )\n", " return final_response" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING:neo4j.notifications:Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.UnknownPropertyKeyWarning} {category: UNRECOGNIZED} {title: The provided property key is not in the database} {description: One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is: full_content)} {position: line: 4, column: 14, offset: 69} for query: '\\n MATCH (c:__Community__)\\n WHERE c.level = $level\\n RETURN c.full_content AS output\\n '\n", "Processing communities: 0it [00:00, ?it/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "I'm sorry, but the provided reports do not contain sufficient information to provide an answer to your question about the major cities of India. If you have any other questions or need information on a different topic, please let me know!\n" ] } ], "source": [ "print(global_retriever(\"Major cities of India?\", 2))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "chatbotenv", "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.11.6" } }, "nbformat": 4, "nbformat_minor": 2 }