From 3a747bf004b060c1eaf48628797ddf8e883e1cd7 Mon Sep 17 00:00:00 2001 From: christinedif <57641517+christinedif@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:19:41 -0400 Subject: [PATCH] Delete notebooks/HelloWork-basic.ipynb - renaming --- notebooks/HelloWork-basic.ipynb | 1678 ------------------------------- 1 file changed, 1678 deletions(-) delete mode 100644 notebooks/HelloWork-basic.ipynb diff --git a/notebooks/HelloWork-basic.ipynb b/notebooks/HelloWork-basic.ipynb deleted file mode 100644 index 53291da0..00000000 --- a/notebooks/HelloWork-basic.ipynb +++ /dev/null @@ -1,1678 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# GraphRAG Basic Walkthrough Demo" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Prerequisites\n", - "Install 3rd party packages that are not part of the Python Standard Library" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: devtools in /graphrag-accelerator/.venv/lib/python3.10/site-packages (0.12.2)\n", - "Requirement already satisfied: pandas in /graphrag-accelerator/.venv/lib/python3.10/site-packages (2.2.2)\n", - "Collecting python-magic\n", - " Downloading python_magic-0.4.27-py2.py3-none-any.whl.metadata (5.8 kB)\n", - "Requirement already satisfied: requests in /graphrag-accelerator/.venv/lib/python3.10/site-packages (2.32.3)\n", - "Requirement already satisfied: tqdm in /graphrag-accelerator/.venv/lib/python3.10/site-packages (4.66.4)\n", - "Requirement already satisfied: asttokens<3.0.0,>=2.0.0 in /graphrag-accelerator/.venv/lib/python3.10/site-packages (from devtools) (2.4.1)\n", - "Requirement already satisfied: executing>=1.1.1 in /graphrag-accelerator/.venv/lib/python3.10/site-packages (from devtools) (2.0.1)\n", - "Requirement already satisfied: pygments>=2.15.0 in /graphrag-accelerator/.venv/lib/python3.10/site-packages (from devtools) (2.18.0)\n", - "Requirement already satisfied: numpy>=1.22.4 in /graphrag-accelerator/.venv/lib/python3.10/site-packages (from pandas) (1.26.4)\n", - "Requirement already satisfied: python-dateutil>=2.8.2 in /graphrag-accelerator/.venv/lib/python3.10/site-packages (from pandas) (2.9.0.post0)\n", - "Requirement already satisfied: pytz>=2020.1 in /graphrag-accelerator/.venv/lib/python3.10/site-packages (from pandas) (2024.1)\n", - "Requirement already satisfied: tzdata>=2022.7 in /graphrag-accelerator/.venv/lib/python3.10/site-packages (from pandas) (2024.1)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /graphrag-accelerator/.venv/lib/python3.10/site-packages (from requests) (3.3.2)\n", - "Requirement already satisfied: idna<4,>=2.5 in /graphrag-accelerator/.venv/lib/python3.10/site-packages (from requests) (3.7)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /graphrag-accelerator/.venv/lib/python3.10/site-packages (from requests) (2.2.1)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /graphrag-accelerator/.venv/lib/python3.10/site-packages (from requests) (2024.6.2)\n", - "Requirement already satisfied: six>=1.12.0 in /graphrag-accelerator/.venv/lib/python3.10/site-packages (from asttokens<3.0.0,>=2.0.0->devtools) (1.16.0)\n", - "Downloading python_magic-0.4.27-py2.py3-none-any.whl (13 kB)\n", - "Installing collected packages: python-magic\n", - "\u001b[31mERROR: Exception:\n", - "Traceback (most recent call last):\n", - " File \"/graphrag-accelerator/.venv/lib/python3.10/site-packages/pip/_internal/cli/base_command.py\", line 180, in exc_logging_wrapper\n", - " status = run_func(*args)\n", - " File \"/graphrag-accelerator/.venv/lib/python3.10/site-packages/pip/_internal/cli/req_command.py\", line 245, in wrapper\n", - " return func(self, options, args)\n", - " File \"/graphrag-accelerator/.venv/lib/python3.10/site-packages/pip/_internal/commands/install.py\", line 452, in run\n", - " installed = install_given_reqs(\n", - " File \"/graphrag-accelerator/.venv/lib/python3.10/site-packages/pip/_internal/req/__init__.py\", line 72, in install_given_reqs\n", - " requirement.install(\n", - " File \"/graphrag-accelerator/.venv/lib/python3.10/site-packages/pip/_internal/req/req_install.py\", line 856, in install\n", - " install_wheel(\n", - " File \"/graphrag-accelerator/.venv/lib/python3.10/site-packages/pip/_internal/operations/install/wheel.py\", line 725, in install_wheel\n", - " _install_wheel(\n", - " File \"/graphrag-accelerator/.venv/lib/python3.10/site-packages/pip/_internal/operations/install/wheel.py\", line 614, in _install_wheel\n", - " assert os.path.exists(pyc_path)\n", - "AssertionError\u001b[0m\u001b[31m\n", - "\u001b[0m" - ] - } - ], - "source": [ - "! pip install devtools pandas python-magic requests tqdm" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "import getpass\n", - "import json\n", - "import sys\n", - "import time\n", - "from pathlib import Path\n", - "\n", - "import magic\n", - "import pandas as pd\n", - "import requests\n", - "from devtools import pprint\n", - "from tqdm import tqdm" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Configuration required by User" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Get API Key for API Management Service\n", - "For authentication, the API requires a *subscription key* to be passed in the header of all requests. To find this key, visit the Azure Portal. The API subscription key will be located under ` --> --> --> --> Primary Key`." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "ocp_apim_subscription_key = getpass.getpass(\n", - " \"Enter the subscription key to the GraphRag APIM:\"\n", - ")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Setup directories and API endpoint\n", - "\n", - "The following parameters are required to access and use the GraphRAG solution accelerator API:\n", - "* file_directory\n", - "* storage_name\n", - "* index_name\n", - "* endpoint\n", - "\n", - "For demonstration purposes, you may use the provided `get-wiki-articles.py` script to download a small set of wikipedia articles or provide your own data." - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [], - "source": [ - "\"\"\"\n", - "These parameters must be defined by the user:\n", - "\n", - "- file_directory: local directory where data files of interest are stored.\n", - "- storage_name: unique name for an Azure blob storage container where files will be uploaded.\n", - "- index_name: unique name for a single knowledge graph construction. Multiple indexes can be created from the same blob container of data.\n", - "- apim_url: the endpoint URL for GraphRAG service (this is the Gateway URL found in the APIM resource).\n", - "\"\"\"\n", - "\n", - "file_directory = \"\"\n", - "storage_name = \"\"\n", - "index_name = \"\"\n", - "apim_url = \"\"" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "assert (\n", - " file_directory != \"\" and storage_name != \"\" and index_name != \"\" and apim_url != \"\"\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "\"\"\"\n", - "\"Ocp-Apim-Subscription-Key\": \n", - " This is a custom HTTP header used by Azure API Management service (APIM) to \n", - " authenticate API requests. The value for this key should be set to the subscription \n", - " key provided by the Azure APIM instance in your GraphRAG resource group.\n", - "\"\"\"\n", - "\n", - "headers = {\"Ocp-Apim-Subscription-Key\": ocp_apim_subscription_key}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Upload Files to Storage Data" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "def upload_files(\n", - " file_directory: str,\n", - " storage_name: str,\n", - " batch_size: int = 100,\n", - " overwrite: bool = True,\n", - " max_retries: int = 5,\n", - ") -> requests.Response | list[Path]:\n", - " \"\"\"\n", - " Upload files to a blob storage container.\n", - "\n", - " Args:\n", - " file_directory - a local directory of .txt files to upload. All files must be in utf-8 encoding.\n", - " storage_name - a unique name for the Azure storage container.\n", - " batch_size - the number of files to upload in a single batch.\n", - " overwrite - whether or not to overwrite files if they already exist in the storage container.\n", - " max_retries - the maximum number of times to retry uploading a batch of files if the API is busy.\n", - "\n", - " NOTE: Uploading files may sometimes fail if the blob container was recently deleted\n", - " (i.e. a few seconds before. The solution \"in practice\" is to sleep a few seconds and try again.\n", - " \"\"\"\n", - " url = apim_url + \"/data\"\n", - "\n", - " def upload_batch(\n", - " files: list, storage_name: str, overwrite: bool, max_retries: int\n", - " ) -> requests.Response:\n", - " for _ in range(max_retries):\n", - " response = requests.post(\n", - " url=url,\n", - " files=files,\n", - " params={\"storage_name\": storage_name, \"overwrite\": overwrite},\n", - " headers=headers,\n", - " )\n", - " # API may be busy, retry\n", - " if response.status_code == 500:\n", - " print(\"API busy. Sleeping and will try again.\")\n", - " time.sleep(10)\n", - " continue\n", - " return response\n", - " return response\n", - "\n", - " batch_files = []\n", - " accepted_file_types = [\"text/plain\"]\n", - " filepaths = list(Path(file_directory).iterdir())\n", - " for file in tqdm(filepaths):\n", - " # validate that file is a file, has acceptable file type, has a .txt extension, and has utf-8 encoding\n", - " if (\n", - " not file.is_file()\n", - " or file.suffix != \".txt\"\n", - " or magic.from_file(str(file), mime=True) not in accepted_file_types\n", - " ):\n", - " print(f\"Skipping invalid file: {file}\")\n", - " continue\n", - " # open and decode file as utf-8, ignore bad characters\n", - " batch_files.append(\n", - " (\"files\", open(file=file, mode=\"r\", encoding=\"utf-8\", errors=\"ignore\"))\n", - " )\n", - " # upload batch of files\n", - " if len(batch_files) == batch_size:\n", - " response = upload_batch(batch_files, storage_name, overwrite, max_retries)\n", - " # if response is not ok, return early\n", - " if not response.ok:\n", - " return response\n", - " batch_files.clear()\n", - " # upload remaining files\n", - " if len(batch_files) > 0:\n", - " response = upload_batch(batch_files, storage_name, overwrite, max_retries)\n", - " return response" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - " 0%| | 0/2 [00:00\n" - ] - } - ], - "source": [ - "response = upload_files(\n", - " file_directory=file_directory,\n", - " storage_name=storage_name,\n", - " batch_size=100,\n", - " overwrite=True,\n", - ")\n", - "if not response.ok:\n", - " print(response.text)\n", - "else:\n", - " print(response)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "List the new existing storage container " - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [], - "source": [ - "def list_files() -> requests.Response:\n", - " \"\"\"List all data storage containers.\"\"\"\n", - " url = apim_url + \"/data\"\n", - " return requests.get(url=url, headers=headers)" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\n", - " 'storage_name': [\n", - " 'test-storage1',\n", - " ],\n", - "}\n" - ] - } - ], - "source": [ - "response = list_files()\n", - "\n", - "pprint(response.json())" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Create an Index\n", - "\n", - "After data files have been uploaded, it is now possible to construct a knowledge graph by creating a search index. If an entity configuration is not provided, a default entity configuration will be used that has been shown to generally work well." - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [], - "source": [ - "def build_index(\n", - " storage_name: str,\n", - " index_name: str,\n", - ") -> requests.Response:\n", - " \"\"\"Create a search index.\n", - " This function kicks off a job that builds a knowledge graph (KG) index from files located in a blob storage container.\n", - " \"\"\"\n", - " url = apim_url + \"/index\"\n", - " request = {\n", - " \"storage_name\": storage_name,\n", - " \"index_name\": index_name\n", - " }\n", - " return requests.post(url, json=request, headers=headers)" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "{\"status\":\"indexing operation has been scheduled.\"}\n" - ] - } - ], - "source": [ - "response = build_index(\n", - " storage_name=storage_name,\n", - " index_name=index_name\n", - ")\n", - "print(response)\n", - "if response.ok:\n", - " print(response.text)\n", - "else:\n", - " print(f\"Failed to submit job.\\nStatus: {response.text}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Note: An indexing job may fail sometimes due to insufficient TPM quota of the GPT-4 turbo model. In this situation, an indexing job can be restarted by re-running the cell above with the same parameters. `graphrag` caches previous indexing results as a cost-savings measure so that restarting indexing jobs will \"pick up\" where the last job stopped." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Check the status of an indexing job\n", - "\n", - "Please wait for your index to reach 100 percent complete before continuing on to the next section to run queries." - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [], - "source": [ - "def index_status(index_name: str) -> requests.Response:\n", - " url = apim_url + f\"/index/status/{index_name}\"\n", - " return requests.get(url, headers=headers)" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\n", - " 'status_code': 200,\n", - " 'index_name': 'cdifonzo-test-index1',\n", - " 'storage_name': 'test-storage1',\n", - " 'entity_config_name': None,\n", - " 'status': 'complete',\n", - " 'percent_complete': 100.0,\n", - " 'progress': '14 out of 14 workflows completed successfully.',\n", - "}\n" - ] - } - ], - "source": [ - "response = index_status(index_name)\n", - "\n", - "pprint(response.json())" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### List indexes\n", - "To view a list of all indexes that exist in the GraphRAG service:" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": {}, - "outputs": [], - "source": [ - "def list_indexes() -> list:\n", - " \"\"\"List all search indexes.\"\"\"\n", - " url = apim_url + \"/index\"\n", - " response = requests.get(url, headers=headers)\n", - " try:\n", - " indexes = json.loads(response.text)\n", - " return indexes[\"index_name\"]\n", - " except json.JSONDecodeError:\n", - " print(response.text)\n", - " return response" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[\n", - " 'cdifonzo-test-index1',\n", - "]\n" - ] - } - ], - "source": [ - "all_indexes = list_indexes()\n", - "pprint(all_indexes)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Query\n", - "\n", - "After an indexing job has completed, the knowledge graph is ready to query. Two types of queries (global and local) are currently supported. In addition, you can issue a query over a single index or multiple indexes." - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": {}, - "outputs": [], - "source": [ - "\"\"\"Needed helper function to parse out the clear result from the query response. \"\"\"\n", - "def parse_query_response(\n", - " response: requests.Response, return_context_data: bool = False\n", - ") -> requests.Response | dict[list[dict]]:\n", - " \"\"\"\n", - " Prints response['result'] value and optionally\n", - " returns associated context data.\n", - " \"\"\"\n", - " if response.ok:\n", - " print(json.loads(response.text)[\"result\"])\n", - " if return_context_data:\n", - " return json.loads(response.text)[\"context_data\"]\n", - " return response\n", - " else:\n", - " print(response.reason)\n", - " print(response.content)\n", - " return response" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Global Search\n", - "\n", - "Global search queries are resource-intensive, but give good responses to questions that require an understanding of the dataset as a whole." - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "metadata": {}, - "outputs": [], - "source": [ - "def global_search(index_name: str | list[str], query: str) -> requests.Response:\n", - " \"\"\"Run a global query over the knowledge graph(s) associated with one or more indexes\"\"\"\n", - " url = apim_url + \"/query/global\"\n", - " request = {\"index_name\": index_name, \"query\": query}\n", - " return requests.post(url, json=request, headers=headers)" - ] - }, - { - "cell_type": "code", - "execution_count": 44, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "# Overview of Main Topics\n", - "\n", - "The dataset provides a multifaceted examination of Arizona and Alaska, covering historical, cultural, political, and economic aspects. Below is a synthesis of the main topics derived from the dataset.\n", - "\n", - "## Historical Significance and Landmarks\n", - "\n", - "Arizona and Alaska boast significant historical landmarks and events. In Arizona, the Japanese American internment camps at Mount Lemmon and the legacy of German POW camps are notable historical points. The Grand Canyon National Park is not only a natural wonder but also a site of historical importance. The Alaska Purchase is a pivotal historical event, with figures such as Alexander II and William H. Seward playing key roles [Data: Reports (4, 3, 7, 13)].\n", - "\n", - "## Community and Cultural Dynamics\n", - "\n", - "The dataset highlights the diverse communities within Arizona, including the Navajo Nation and the influence of religious organizations like the Roman Catholic Church and the Church of Jesus Christ of Latter-day Saints. In Alaska, the University of Alaska Fairbanks stands out for its efforts in preserving indigenous languages through the Alaska Native Language Center, reflecting the state's cultural priorities [Data: Reports (0, 12)].\n", - "\n", - "## Political Landscape and Legislation\n", - "\n", - "Arizona's political history is marked by influential figures and shifting party dominance, with discussions on the state's stringent immigration law, SB 1070, and its review by the Supreme Court. The legacy of voting rights in Maricopa County is also noted. Alaska's political significance is underscored by its representation in Congress and the McCain-Palin 2008 Presidential Campaign [Data: Reports (0, 10, 8, 9, 11)].\n", - "\n", - "## Economic and Social Contributions\n", - "\n", - "The economic benefits of tourism and retirement communities in Arizona are significant, as is the state's role in national and international relations. Flagstaff is highlighted as a strategic hub for transportation and tourism in northern Arizona [Data: Reports (0, 6)].\n", - "\n", - "## Education and Research\n", - "\n", - "Arizona's major public universities contribute to the state's development, while the University of Alaska Fairbanks is recognized for its political significance and cultural studies, especially in indigenous language preservation [Data: Reports (0, 12)].\n", - "\n", - "## Natural Resources and Conservation\n", - "\n", - "The Grand Canyon National Park and the Colorado River are central to discussions on natural resources and conservation in Arizona. Alaska's reliance on natural resources like petroleum and its conservation efforts are also key topics [Data: Reports (7, +more)].\n", - "\n", - "In summary, the dataset encapsulates the rich tapestry of Arizona and Alaska's historical landmarks, cultural diversity, political developments, economic contributions, educational institutions, and natural resource management. Each state presents a unique blend of these elements, shaping their identities and roles within the broader American context.\n", - "CPU times: user 20.9 ms, sys: 1.5 ms, total: 22.4 ms\n", - "Wall time: 1min 19s\n" - ] - }, - { - "data": { - "text/plain": [ - "{'reports': [{'id': '4',\n", - " 'title': 'Japanese American Internment at Mount Lemmon',\n", - " 'content': \"# Japanese American Internment at Mount Lemmon\\n\\nThis report examines the historical community associated with the Japanese American internment camps during World War II, specifically focusing on the camp located at Mount Lemmon, Arizona. The entities involved include the state of Arizona and the specific location of Mount Lemmon.\\n\\n## Historical significance of Japanese American internment camps\\n\\nThe Japanese American internment camps represent a critical period in American history where persons of Japanese descent were forcibly relocated and interned due to wartime fears. These camps are a stark reminder of the consequences of wartime hysteria and racial prejudice, which led to the violation of civil liberties and rights of American citizens and residents. The internment has had a lasting impact on the Japanese American community and continues to be a subject of reflection and education on civil rights [Data: Entities (29)].\\n\\n## Mount Lemmon's role in the internment\\n\\nMount Lemmon, located outside Tucson, Arizona, was one of the sites for these internment camps. The presence of an internment camp at Mount Lemmon is a significant historical fact that contributes to the understanding of the geographic spread and living conditions of the internment process. It also serves as a specific example of the broader phenomenon of internment across the United States during that period [Data: Entities (31), Relationships (74)].\\n\\n## Arizona's involvement in the internment\\n\\nThe state of Arizona played a role in the internment of Japanese Americans by hosting internment camps within its borders. This involvement is part of the larger narrative of state participation in the internment process, which was a federal mandate but required local implementation. The historical record of Arizona's involvement provides insight into how different states complied with and facilitated the internment of Japanese Americans [Data: Relationships (18)].\",\n", - " 'rank': '8.0',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '4'},\n", - " {'id': '3',\n", - " 'title': \"Arizona's WWII German POW Camps Legacy\",\n", - " 'content': \"# Arizona's WWII German POW Camps Legacy\\n\\nThe community's history is rooted in the presence of German POW camps in Arizona during World War II, with the Phoenix Zoo and the Gila River area being significant post-war landmarks that evolved from these sites.\\n\\n## Historical significance of German POW camps in Arizona\\n\\nThe German Prisoner of War camps in Arizona are of historical importance, having housed German POWs during World War II. These camps are a reminder of the global reach of the war and its impact on American soil. The presence of these camps highlights Arizona's role in the larger context of the war and post-war developments. [Data: Entities (28); Relationships (17)]\\n\\n## Transformation of POW camp into Phoenix Zoo\\n\\nThe site of one of the former German POW camps has been transformed into the Phoenix Zoo, a significant cultural and educational institution in the region. This transformation from a wartime facility to a place of conservation and learning represents a notable shift in the use of land and resources, as well as a change in societal values and priorities. The involvement of the Maytag family in purchasing the land after the war indicates the private sector's role in repurposing historical sites. [Data: Entities (30); Relationships (72)]\\n\\n## Gila River's proximity to a former POW camp\\n\\nThe Gila River area, known for its proximity to another POW camp, is part of the community's historical narrative. The river's location in eastern Yuma County, Arizona, adds a geographical dimension to the history of POW camps in the state. The Gila River itself may have been a significant factor in the placement of the camp during the war, and it continues to be a natural landmark in the region. [Data: Entities (32); Relationships (73)]\",\n", - " 'rank': '3.0',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '3'},\n", - " {'id': '7',\n", - " 'title': 'Grand Canyon National Park and Its Historical Significance',\n", - " 'content': \"# Grand Canyon National Park and Its Historical Significance\\n\\nThe Grand Canyon National Park is a pivotal natural entity, recognized as one of the world's seven natural wonders and closely associated with the Colorado River and President Theodore Roosevelt. The park's historical and natural significance is underscored by its relationship with these entities.\\n\\n## Grand Canyon National Park as a natural wonder\\n\\nGrand Canyon National Park is not only a national treasure but also a globally recognized natural wonder. Its vast and unique geological formations offer insights into the earth's history and provide significant value for scientific research, education, and tourism. The park's degree of connectivity within the community is highlighted by its relationships with other key entities, emphasizing its central role in the network [Data: Entities (10); Relationships (1, 68, 67)].\\n\\n## Colorado River's role in shaping the Grand Canyon\\n\\nThe Colorado River is an integral part of the Grand Canyon's history and present state. Over millions of years, the river has carved the canyon, creating the magnificent landscape that we see today. This natural process not only demonstrates the river's power but also its importance in the formation of the Grand Canyon, making it a subject of interest for geologists and tourists alike [Data: Entities (51); Relationships (68)].\\n\\n## Theodore Roosevelt's advocacy for the Grand Canyon\\n\\nTheodore Roosevelt's influence on the Grand Canyon's preservation is a testament to his commitment to conservation. As the 26th President of the United States, his advocacy was crucial in the designation of the Grand Canyon area as a National Park. This historical relationship underscores the importance of political will in the conservation of natural landmarks and Roosevelt's lasting legacy in environmental protection [Data: Entities (50); Relationships (67)].\",\n", - " 'rank': '8.5',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '7'},\n", - " {'id': '0',\n", - " 'title': 'Arizona: A Mosaic of Communities, History, and Politics',\n", - " 'content': \"# Arizona: A Mosaic of Communities, History, and Politics\\n\\nArizona is a state with a rich tapestry of communities, historical events, and political entities. Its entities range from major public universities and Native American nations to political figures and historical landmarks. The relationships between these entities highlight the state's diverse cultural, educational, and political landscape.\\n\\n## Arizona's Educational Institutions as Pillars of the Community\\n\\nArizona's major public universities, the University of Arizona and Arizona State University, are central to the state's higher education and research. They provide academic programs and opportunities to a large student body, contributing to the state's intellectual and economic development [Data: Entities (11, 12); Relationships (2, 3)]. Northern Arizona University further complements the state's educational landscape, serving additional communities within Arizona [Data: Relationships (62)].\\n\\n## The Navajo Nation's Unique Cultural and Political Presence\\n\\nThe Navajo Nation, as the largest Native American tribe in the U.S., holds a significant territory predominantly in Arizona. It has a unique cultural and political influence, including the observance of Daylight Saving Time, which differs from the rest of Arizona [Data: Entities (15); Relationships (4)].\\n\\n## Religious Organizations and Their Influence in Arizona\\n\\nThe Roman Catholic Church and the Church of Jesus Christ of Latter-day Saints have substantial followings in Arizona. Their presence reflects the state's religious diversity and the potential influence these organizations may have on local communities and politics [Data: Entities (16, 17); Relationships (5, 6)].\\n\\n## Arizona's Political Landscape Shaped by Key Figures and Parties\\n\\nArizona's political history is marked by influential figures such as Barry Goldwater and Gabby Giffords, as well as the shifting dominance between the Democratic and Republican parties. These dynamics have shaped the state's political discourse and policies over the years [Data: Entities (13, 46); Relationships (7, 55, 56)].\\n\\n## Tourism and Retirement Communities as Economic Contributors\\n\\nArizona's economy benefits from tourism, with dude ranches and resorts contributing to the state's appeal. Retirement communities like Sun City and Green Valley also play a role in the state's demographic and economic profile [Data: Entities (22, 23, 24, 25, 26, 27, 38, 39); Relationships (11, 12, 13, 14, 15, 16, 20, 21)].\\n\\n## Arizona's Role in National and International Relations\\n\\nArizona's geographical position adjacent to other U.S. states and Mexican states like Sonora and Baja California facilitates cross-border cultural and economic exchanges. This positioning underscores the state's role in broader national and international contexts [Data: Entities (3, 4, 5, 6, 53, 54); Relationships (27, 28, 29, 30, 31, 32, 33)].\\n\\n## Historical Landmarks and Events Commemorating Arizona's Past\\n\\nHistorical landmarks such as the USS Arizona and the Barringer Meteorite Crater, along with events like the Great Depression and World War II internment camps, are part of Arizona's complex history. These sites and events are reminders of the state's past and its impact on the present [Data: Entities (21, 47, 52); Relationships (10, 17, 18, 25, 26)].\",\n", - " 'rank': '7.5',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '0'},\n", - " {'id': '13',\n", - " 'title': 'The Alaska Purchase: Alexander II and William H. Seward',\n", - " 'content': \"# The Alaska Purchase: Alexander II and William H. Seward\\n\\nThe community's structure is centered around the historical event of the Alaska Purchase, involving key figures Alexander II and William H. Seward. Their relationship and actions led to the transfer of Alaska from Russia to the United States.\\n\\n## Alexander II's pivotal role in the Alaska Purchase\\n\\nAlexander II, as the Emperor of the Russian Empire, played a crucial role in the sale of Alaska to the U.S. His decision to sell the territory had lasting implications on the geopolitical landscape of North America. The sale not only altered the territorial boundaries but also had economic and strategic consequences for both nations involved. Alexander II's willingness to engage in this transaction indicates Russia's strategic considerations at the time, possibly including financial pressures and the desire to reduce the empire's overextended reach [Data: Entities (148), Relationships (107)].\\n\\n## William H. Seward's negotiation of the Alaska Purchase\\n\\nWilliam H. Seward, as the United States Secretary of State, was instrumental in negotiating the Alaska Purchase. His foresight and determination in acquiring Alaska were met with both criticism and acclaim. The purchase, initially termed 'Seward's Folly' by skeptics, eventually proved to be a strategic and resource-rich addition to the United States. Seward's role in this transaction highlights the importance of diplomatic negotiations and the long-term vision in foreign policy [Data: Entities (149), Relationships (108)].\\n\\n## The direct negotiation between Alexander II and William H. Seward\\n\\nThe direct involvement of both Alexander II and William H. Seward in the negotiations of the Alaska Purchase underscores the significance of the deal. The high rank of the individuals involved suggests that the purchase was a matter of considerable importance to both nations. The collaboration between these two key figures led to a peaceful transfer of territory, which is a notable example of international diplomacy and bilateral relations [Data: Relationships (139)].\",\n", - " 'rank': '8.0',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '13'},\n", - " {'id': '10',\n", - " 'title': \"Arizona's Immigration Legislation and Judicial Review\",\n", - " 'content': \"# Arizona's Immigration Legislation and Judicial Review\\n\\nThis community is centered around Arizona's immigration policies, particularly SB 1070, known as the toughest immigration law in the United States, and its interactions with the Supreme Court of the United States, which has invalidated parts of the law. Proposition 200, another Arizona law requiring proof of citizenship to register to vote, was also struck down by the Supreme Court.\\n\\n## SB 1070's role as a stringent immigration law\\n\\nSB 1070 stands as a pivotal piece of legislation in Arizona's history, reflecting a strict stance on immigration enforcement. The requirement for immigrants to carry their papers at all times has been a subject of national debate and controversy. The law's impact extends beyond Arizona, influencing immigration policy discussions across the United States. The Supreme Court's involvement in partially striking down the law underscores its legal and constitutional significance [Data: Entities (44); Relationships (61, 80)].\\n\\n## The Supreme Court's influence on Arizona's immigration laws\\n\\nThe Supreme Court of the United States has played a critical role in shaping the legal landscape of immigration in Arizona. By striking down parts of SB 1070, the Court has set a precedent that affects the enforcement of immigration laws and the balance of power between state and federal jurisdictions. This judicial review process reflects the checks and balances inherent in the U.S. legal system and has far-reaching implications for immigration policy and civil rights [Data: Entities (43); Relationships (80)].\\n\\n## The impact of Proposition 200's rejection\\n\\nProposition 200, which aimed to require proof of citizenship for voter registration in Arizona, represents another facet of the state's approach to policy-making regarding immigration and citizenship. The Supreme Court's decision to strike down this proposition indicates the judiciary's role in protecting voting rights and ensuring that state laws comply with federal standards. This decision has implications for voter registration processes and the broader discourse on voter rights and immigration [Data: Entities (42); Relationships (79)].\",\n", - " 'rank': '7.5',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '10'},\n", - " {'id': '6',\n", - " 'title': 'Flagstaff and Coconino County Community Report',\n", - " 'content': \"# Flagstaff and Coconino County Community Report\\n\\nThe community report focuses on Flagstaff, a key city within Coconino County, Arizona. Flagstaff is recognized for its strategic location, serving as a hub for transportation and tourism in northern Arizona. The city's relationship with Coconino County and the state of Arizona highlights its importance in the region.\\n\\n## Flagstaff as a pivotal city in northern Arizona\\n\\nFlagstaff is identified as the largest city in northern Arizona, known for its high elevation and scenic pine forests. The city's transportation systems, including public bus transit and Amtrak, are crucial for facilitating movement for both residents and visitors. Flagstaff's proximity to the Grand Canyon and other natural attractions makes it a vital tourist destination, which can have a substantial impact on the local and regional economy. [Data: Entities (60); Relationships (40)]\\n\\n## Coconino County's relationship with Flagstaff\\n\\nCoconino County, which encompasses Flagstaff, benefits from the city's status as a major urban center. The county's association with Flagstaff enhances its visibility and importance within the state of Arizona. As the largest city in the county, Flagstaff's economic health and tourist appeal directly influence the county's prosperity and development. [Data: Entities (61); Relationships (85)]\\n\\n## Flagstaff's transportation significance\\n\\nThe city's transportation infrastructure, highlighted by its public bus transit systems and Amtrak services, positions Flagstaff as a key transportation node in the region. This infrastructure not only supports the city's residents but also caters to the influx of tourists, thereby amplifying its impact on regional connectivity and economic growth. [Data: Entities (60); Relationships (40)]\",\n", - " 'rank': '6.5',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '6'},\n", - " {'id': '12',\n", - " 'title': 'University of Alaska Fairbanks and Alaska Native Language Center',\n", - " 'content': \"# University of Alaska Fairbanks and Alaska Native Language Center\\n\\nThe University of Alaska Fairbanks is a key educational institution in Alaska, recognized for its Democratic leanings and its dedication to the study and preservation of Alaska's indigenous languages through the Alaska Native Language Center.\\n\\n## University of Alaska Fairbanks as a Democratic stronghold\\n\\nThe University of Alaska Fairbanks (UAF) is noted for its political significance as a Democratic stronghold in a state that is traditionally Republican. This political leaning could have implications for state and local elections, as well as for the shaping of policy, particularly in areas of education and cultural preservation. The university's role in the political landscape of Alaska is therefore of considerable interest to political analysts and strategists [Data: Entities (186)].\\n\\n## Alaska Native Language Center's role in cultural preservation\\n\\nThe Alaska Native Language Center (ANLC), located within UAF, is dedicated to the research and preservation of indigenous languages of Alaska. This center plays a critical role in maintaining the linguistic heritage of the state, which is of great cultural and academic importance. The work done by the ANLC not only contributes to the field of linguistics but also supports the cultural identity and rights of Alaska's indigenous populations [Data: Entities (185)].\\n\\n## Interconnectedness of UAF and ANLC\\n\\nThe relationship between UAF and ANLC is symbiotic, with the university providing a platform for the center's activities. This interconnectedness enhances the university's reputation as a hub for cultural studies and indigenous language preservation. The ANLC's presence on campus may also contribute to the university's political leaning by fostering a community that values diversity and cultural heritage [Data: Relationships (147)].\\n\\n## UAF's geographical and political significance\\n\\nUAF's location in Alaska positions it as a central institution in the state's higher education system. Its status as a Democratic stronghold within a predominantly Republican state adds to its political significance. The university's influence extends beyond academia into the political sphere, potentially affecting local and state policies and elections [Data: Entities (186), Relationships (128)].\",\n", - " 'rank': '6.5',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '12'},\n", - " {'id': '8',\n", - " 'title': 'Maricopa County and the Legacy of Voting Rights',\n", - " 'content': \"# Maricopa County and the Legacy of Voting Rights\\n\\nMaricopa County, encompassing Phoenix and its metropolitan area, is a pivotal community in Arizona with historical significance due to the landmark Harrison and Austin v. Laveen case. The county's relationship with Phoenix, the Fort McDowell Yavapai Nation, and the Valley Metro Rail highlights its centrality in the state's political, cultural, and transportation dynamics.\\n\\n## Maricopa County's pivotal role in Arizona\\n\\nMaricopa County is the largest county in Arizona and plays a significant role in the state's politics, being home to the majority of the state's population and the capital city, Phoenix [Data: Entities (36); Relationships (57)]. The county's historical moment of allowing Native Americans to vote following the Arizona Supreme Court ruling showcases its impact on civil rights and the political landscape [Data: Entities (36)].\\n\\n## Phoenix as the capital within Maricopa County\\n\\nPhoenix, as the capital and largest city of Arizona, is renowned for its climate and serves as the location of the state capitol complex. Its connection to Maricopa County underscores the city's importance in state governance and its influence on regional affairs [Data: Entities (1); Relationships (0, 65)].\\n\\n## Frank Harrison and Harry Austin's advocacy for voting rights\\n\\nFrank Harrison and Harry Austin, both members of the Fort McDowell Yavapai Nation, played a crucial role in advocating for Native American voting rights through their legal challenge against Maricopa County's exclusionary practices. Their case, Harrison and Austin v. Laveen, marked a significant moment in the fight for civil rights and has had a lasting impact on the community [Data: Entities (34, 35); Relationships (75, 77)].\\n\\n## Fort McDowell Yavapai Nation's involvement in civil rights\\n\\nThe Fort McDowell Yavapai Nation's involvement in the landmark voting rights case illustrates the tribe's commitment to civil rights and its historical struggle for recognition and equality. The case brought by its members against Maricopa County has had a profound effect on the community and the state's legal precedents [Data: Entities (92); Relationships (76, 78)].\\n\\n## Valley Metro Rail's connectivity in the region\\n\\nThe Valley Metro Rail serves as a critical transportation link connecting Phoenix with other cities such as Mesa and Tempe. This infrastructure highlights the interconnectedness of the community and facilitates the mobility of residents within Maricopa County and beyond [Data: Entities (74); Relationships (66)].\",\n", - " 'rank': '7.5',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '8'},\n", - " {'id': '2',\n", - " 'title': 'Anchorage: Resilience and Cultural Expansion',\n", - " 'content': \"# Anchorage: Resilience and Cultural Expansion\\n\\nAnchorage, Alaska's largest city, is a hub of resilience and cultural diversity, evidenced by its recovery from the Good Friday Earthquake and the ongoing expansion of its religious infrastructure, such as the construction of the first mosque by the Islamic Community Center. The city's connectivity is enhanced by the Alaska Railroad, and it is also the starting point for the Iditarod Trail Sled Dog Race, showcasing its unique cultural events.\\n\\n## Anchorage's historical resilience post-earthquake\\n\\nAnchorage demonstrated remarkable resilience following the Good Friday Earthquake, which was one of the most powerful earthquakes ever recorded. The city's ability to recover and develop after such a significant disaster highlights its robust infrastructure and community strength. This historical event has shaped the city's approach to disaster preparedness and urban planning [Data: Entities (144, 152); Relationships (132)].\\n\\n## Cultural diversity reflected in religious infrastructure\\n\\nThe Islamic Community Center of Anchorage's efforts to construct the city's first mosque is a testament to the cultural and religious diversity within the community. This expansion of religious infrastructure indicates a growing and evolving demographic, which contributes to the city's rich cultural tapestry [Data: Entities (144, 194); Relationships (136)].\\n\\n## Connectivity through the Alaska Railroad\\n\\nThe Alaska Railroad plays a crucial role in Anchorage's connectivity, linking the city to other parts of the state and facilitating both local and international travel. This transportation system is vital for the movement of goods and people, underpinning the city's economic framework [Data: Entities (144, 230); Relationships (137)].\\n\\n## Significance of the Iditarod Trail Sled Dog Race\\n\\nThe Iditarod Trail Sled Dog Race, starting in Anchorage, is not only a significant cultural event but also a draw for tourism and international attention. This annual race is a symbol of Alaska's unique heritage and contributes to the community's identity [Data: Entities (144, 239); Relationships (138)].\\n\\n## Influential figures in Anchorage's earthquake recovery\\n\\nIndividuals such as Lidia Selkregg, Ruth A. M. Schmidt, and Genie Chance played pivotal roles in Anchorage's recovery from the Good Friday Earthquake. Their contributions to damage assessment, relief efforts, and information dissemination were critical in the aftermath of the disaster, showcasing the importance of leadership in times of crisis [Data: Entities (156, 157, 159); Relationships (133, 134, 135)].\",\n", - " 'rank': '7.5',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '2'},\n", - " {'id': '5',\n", - " 'title': 'Tucson and Pima County: A Synergistic Arizona Community',\n", - " 'content': \"# Tucson and Pima County: A Synergistic Arizona Community\\n\\nThe community is centered around Tucson, the second-largest city in Arizona, which is part of Pima County. The city is known for its public transportation systems, including the Sun Link streetcar, and is in close proximity to Saguaro National Park. Pima County is recognized for its Democratic voting history. The entities are interconnected, with Tucson serving as a hub for transportation, education, and natural conservation.\\n\\n## Tucson as a pivotal urban center\\n\\nTucson stands as a pivotal urban center within Arizona, housing the University of Arizona and serving as a transportation hub with its public bus transit systems and the Sun Link streetcar system. The city's substantial metro population contributes to its economic and cultural significance in the state. Tucson's role as a central entity is underscored by its connections to surrounding areas and its influence on regional development [Data: Entities (56); Relationships (38, 82, 81, 83)].\\n\\n## Pima County's political landscape\\n\\nPima County, encompassing Tucson and its suburbs, is notable for its historical tendency to vote Democratic in political elections. This political leaning differentiates the county within a state that has varied political affiliations and may influence regional policies and the political discourse. The county's relationship with Tucson enhances its importance, as the city's population and institutions contribute to the county's political character [Data: Entities (57); Relationships (58, 82)].\\n\\n## Saguaro National Park's environmental significance\\n\\nSaguaro National Park is an environmental treasure located just west of Tucson, celebrated for its vast collection of Saguaro cacti. The park's proximity to Tucson enhances the city's appeal as a destination for nature enthusiasts and contributes to the conservation of the unique desert landscape. The park's identity is deeply intertwined with the cultural and natural heritage of the region [Data: Entities (48); Relationships (81)].\\n\\n## Sun Link's contribution to Tucson's connectivity\\n\\nThe Sun Link streetcar system is a critical component of Tucson's public transportation infrastructure, connecting the University of Arizona campus with downtown areas. This connectivity fosters accessibility and mobility within the city, supporting both local residents and the student population. Sun Link's operation within Tucson underscores the city's commitment to sustainable transportation solutions [Data: Entities (75); Relationships (83)].\",\n", - " 'rank': '6.5',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '5'},\n", - " {'id': '11',\n", - " 'title': 'Alaska: A Mosaic of History, Policy, and Culture',\n", - " 'content': \"# Alaska: A Mosaic of History, Policy, and Culture\\n\\nAlaska's community is characterized by its unique historical, political, and cultural landscape. Key entities include the state's relationship with federal agencies like HUD, its political representation, and its cultural heritage as reflected in religious institutions and historical events. The community's structure is informed by its geographical position, economic dependencies, and the diverse makeup of its population.\\n\\n## HUD's role in addressing housing and homelessness in Alaska\\n\\nThe United States Department of Housing and Urban Development (HUD) plays a pivotal role in addressing housing needs and homelessness in Alaska, as evidenced by its reports that include data on the state [Data: Entities (66); Relationships (35, 88)]. HUD's mandate to prepare the Annual Homeless Assessment Report is crucial for understanding and addressing the homelessness situation in Alaska, which has implications for social policy and federal funding [Data: Entities (66)].\\n\\n## Alaska's political significance reflected in presidential elections\\n\\nAlaska's political landscape is marked by its electoral significance, as seen in the 2020 presidential election where Joe Biden received votes, and historical figures like James Wickersham advocating for statehood [Data: Entities (93, 151); Relationships (59, 89, 110)]. The state's political leanings and representation in Congress, with figures like Mary Peltola and Don Young, also highlight its role in national politics [Data: Entities (255, 256); Relationships (127, 129, 130, 131)].\\n\\n## Geopolitical and economic relationships of Alaska\\n\\nAlaska's position as a non-contiguous state shapes its geopolitical and economic relationships. It shares borders with Canadian territories and a maritime border with Russia, impacting trade, security, and international relations [Data: Entities (133, 135, 136, 137); Relationships (96, 97, 98, 99)]. Alaska's economy, heavily reliant on natural resources like petroleum, is influenced by these relationships and its tax policies [Data: Entities (133, 248, 249); Relationships (125, 126)].\\n\\n## Cultural diversity and religious heritage in Alaska\\n\\nAlaska's cultural diversity is reflected in its religious heritage, with organizations like the Association of Religion Data Archives and the Pew Research Center providing data on religious adherents and practices [Data: Entities (187, 188, 189, 190); Relationships (118, 119, 120, 121)]. The presence of the Russian Orthodox Church and the Sri Ganesha Temple of Alaska signifies the integration of different cultures and religious beliefs [Data: Entities (192, 193); Relationships (122, 123)].\\n\\n## Historical significance and conservation efforts in Alaska\\n\\nAlaska's history is marked by events like the Alaska Purchase and the Good Friday Earthquake, which have shaped its development and identity [Data: Entities (146, 147, 150, 158); Relationships (105, 106, 109, 111)]. Conservation efforts, such as the Alaska National Interest Lands Conservation Act, demonstrate the state's commitment to preserving its natural beauty and resources [Data: Entities (164); Relationships (114)].\",\n", - " 'rank': '7.5',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '11'},\n", - " {'id': '9',\n", - " 'title': 'McCain-Palin 2008 Presidential Campaign',\n", - " 'content': \"# McCain-Palin 2008 Presidential Campaign\\n\\nThe community is centered around the political partnership of John McCain and Sarah Palin during the 2008 presidential election, with connections to Arizona and Alaska. McCain's influence as a Senator and presidential nominee, along with Palin's historic vice-presidential candidacy, are significant elements of this community.\\n\\n## John McCain's political legacy\\n\\nJohn McCain was a prominent figure in American politics, serving as a Senator from Arizona and the Republican presidential nominee in 2008. His political career was marked by his conservative stance and his influence within the Republican Party. McCain's role in the 2008 presidential race, although not victorious, left a lasting impact on the political landscape. [Data: Entities (14); Relationships (8, 69)]\\n\\n## Sarah Palin's historic candidacy\\n\\nSarah Palin's selection as John McCain's running mate was historic, as she became the first Alaskan on a major party ticket and the second woman to run for vice president on a major party's ticket in the United States. Her candidacy brought significant attention to the McCain campaign and had a lasting impact on the political discourse. [Data: Entities (251); Relationships (70)]\\n\\n## Arizona's role in McCain's career\\n\\nArizona, as John McCain's home state, played a crucial role in his political career. McCain's representation of Arizona in the Senate and his connection to the state's electorate were foundational to his national political presence. [Data: Relationships (8)]\\n\\n## Alaska's electoral support for McCain\\n\\nIn the 2008 presidential election, John McCain won the electoral votes of Alaska, demonstrating the state's support for the McCain-Palin ticket. This support was likely bolstered by Palin's position as the governor of Alaska and her presence on the ticket. [Data: Relationships (69)]\",\n", - " 'rank': '7.5',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '9'}],\n", - " 'entities': [],\n", - " 'relationships': [],\n", - " 'claims': []}" - ] - }, - "execution_count": 44, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "%%time\n", - "# pass in a single index name as a string or to query across multiple indexes, set index_name=[myindex1, myindex2]\n", - "global_response = global_search(\n", - " index_name=index_name, query=\"Summarize the main topics of this data\"\n", - ")\n", - "# print the result and save context data in a variable\n", - "global_response_data = parse_query_response(global_response, return_context_data=True)\n", - "global_response_data" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "An *experimental* API endpoint has been designed to support streaming back the graphrag response while executing a global query (useful in chatbot applications)." - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": {}, - "outputs": [], - "source": [ - "def global_search_streaming(\n", - " index_name: str | list[str], query: str\n", - ") -> requests.Response:\n", - " \"\"\"Run a global query across one or more indexes and stream back the response\"\"\"\n", - " url = apim_url + \"/experimental/query/global/streaming\"\n", - " request = {\"index_name\": index_name, \"query\": query}\n", - " context_list = []\n", - " with requests.post(url, json=request, headers=headers, stream=True) as r:\n", - " r.raise_for_status()\n", - " for chunk in r.iter_lines(chunk_size=256 * 1024, decode_unicode=True):\n", - " try:\n", - " payload = json.loads(chunk)\n", - " token = payload[\"token\"]\n", - " context = payload[\"context\"]\n", - " if token != \"\":\n", - " print(token, end=\"\")\n", - " elif (token == \"\") and not context:\n", - " print(\"\\n\") # transition from output message to context\n", - " else:\n", - " context_list.append(context)\n", - " except json.JSONDecodeError:\n", - " print(type(chunk), len(chunk), sys.getsizeof(chunk), chunk, end=\"\\n\")\n", - " display(pd.DataFrame.from_dict(context_list).head(10))" - ] - }, - { - "cell_type": "code", - "execution_count": 46, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "# Overview of Arizona and Alaska\n", - "\n", - "The dataset provides a rich tapestry of historical, political, and cultural insights into the states of Arizona and Alaska. It captures the essence of significant events and entities that have left an indelible mark on the communities within these states.\n", - "\n", - "## Arizona's Historical and Cultural Significance\n", - "\n", - "### World War II Impact\n", - "Arizona's history is deeply intertwined with World War II. The internment of Japanese Americans is a stark reminder of the civil liberties challenges during the war, with Mount Lemmon serving as one of the internment sites [Data: Reports (4)]. Additionally, the state hosted German POW camps, one of which was later transformed into the Phoenix Zoo, indicating a complex legacy of the war [Data: Reports (3)].\n", - "\n", - "### Natural Heritage\n", - "The Grand Canyon National Park stands as a testament to Arizona's natural heritage. Carved by the Colorado River, it was preserved due to the efforts of President Theodore Roosevelt, emphasizing its environmental and historical significance [Data: Reports (7)].\n", - "\n", - "## Arizona's Community and Political Landscape\n", - "\n", - "### Education and Culture\n", - "Arizona's educational institutions, notably the University of Arizona and Arizona State University, are cornerstones of the state's development [Data: Reports (0)]. The Navajo Nation adds to the cultural mosaic with its unique traditions, including its stance on Daylight Saving Time [Data: Reports (0)].\n", - "\n", - "### Religion and Politics\n", - "Religious organizations, particularly the Roman Catholic Church and the Church of Jesus Christ of Latter-day Saints, exert considerable influence in Arizona [Data: Reports (0)]. Politically, the state has been shaped by figures such as Barry Goldwater and Gabby Giffords, reflecting the interplay between major political parties [Data: Reports (0)].\n", - "\n", - "### Economy and International Relations\n", - "Tourism and retirement communities are pivotal to Arizona's economy, influencing its demographic and economic landscape [Data: Reports (0)]. The state's geographical position fosters cross-border exchanges with Mexico, highlighting its role in national and international relations [Data: Reports (0)].\n", - "\n", - "### Historical Landmarks\n", - "Landmarks like the USS Arizona and the Barringer Meteorite Crater serve as historical commemorations of Arizona's past [Data: Reports (0)].\n", - "\n", - "## Alaska's Historical and Cultural Context\n", - "\n", - "### The Alaska Purchase\n", - "The Alaska Purchase is a cornerstone event in North American history, involving key figures such as Alexander II of Russia and William H. Seward, the American Secretary of State who orchestrated the acquisition [Data: Reports (0)].\n", - "\n", - "The dataset paints a vivid picture of how Arizona and Alaska have evolved over time, shaped by their unique historical events and cultural landscapes. Each state's distinct identity is a product of its past, from the trials of war to the stewardship of natural wonders, and from the influence of educational institutions to the interplay of political forces.\n", - "\n" - ] - }, - { - "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", - " \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", - " \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", - "
idtitlecontentrankindex_nameindex_id
04Japanese American Internment at Mount Lemmon# Japanese American Internment at Mount Lemmon...8.0af20e88224165cf5ea4fe06f0aae63ca4
13Arizona's WWII German POW Camps Legacy# Arizona's WWII German POW Camps Legacy\\n\\nTh...3.0af20e88224165cf5ea4fe06f0aae63ca3
27Grand Canyon National Park and Its Historical ...# Grand Canyon National Park and Its Historica...8.5af20e88224165cf5ea4fe06f0aae63ca7
30Arizona: A Mosaic of Communities, History, and...# Arizona: A Mosaic of Communities, History, a...7.5af20e88224165cf5ea4fe06f0aae63ca0
413The Alaska Purchase: Alexander II and William ...# The Alaska Purchase: Alexander II and Willia...8.0af20e88224165cf5ea4fe06f0aae63ca13
510Arizona's Immigration Legislation and Judicial...# Arizona's Immigration Legislation and Judici...7.5af20e88224165cf5ea4fe06f0aae63ca10
66Flagstaff and Coconino County Community Report# Flagstaff and Coconino County Community Repo...6.5af20e88224165cf5ea4fe06f0aae63ca6
712University of Alaska Fairbanks and Alaska Nati...# University of Alaska Fairbanks and Alaska Na...6.5af20e88224165cf5ea4fe06f0aae63ca12
88Maricopa County and the Legacy of Voting Rights# Maricopa County and the Legacy of Voting Rig...7.5af20e88224165cf5ea4fe06f0aae63ca8
92Anchorage: Resilience and Cultural Expansion# Anchorage: Resilience and Cultural Expansion...7.5af20e88224165cf5ea4fe06f0aae63ca2
\n", - "
" - ], - "text/plain": [ - " id title \\\n", - "0 4 Japanese American Internment at Mount Lemmon \n", - "1 3 Arizona's WWII German POW Camps Legacy \n", - "2 7 Grand Canyon National Park and Its Historical ... \n", - "3 0 Arizona: A Mosaic of Communities, History, and... \n", - "4 13 The Alaska Purchase: Alexander II and William ... \n", - "5 10 Arizona's Immigration Legislation and Judicial... \n", - "6 6 Flagstaff and Coconino County Community Report \n", - "7 12 University of Alaska Fairbanks and Alaska Nati... \n", - "8 8 Maricopa County and the Legacy of Voting Rights \n", - "9 2 Anchorage: Resilience and Cultural Expansion \n", - "\n", - " content rank \\\n", - "0 # Japanese American Internment at Mount Lemmon... 8.0 \n", - "1 # Arizona's WWII German POW Camps Legacy\\n\\nTh... 3.0 \n", - "2 # Grand Canyon National Park and Its Historica... 8.5 \n", - "3 # Arizona: A Mosaic of Communities, History, a... 7.5 \n", - "4 # The Alaska Purchase: Alexander II and Willia... 8.0 \n", - "5 # Arizona's Immigration Legislation and Judici... 7.5 \n", - "6 # Flagstaff and Coconino County Community Repo... 6.5 \n", - "7 # University of Alaska Fairbanks and Alaska Na... 6.5 \n", - "8 # Maricopa County and the Legacy of Voting Rig... 7.5 \n", - "9 # Anchorage: Resilience and Cultural Expansion... 7.5 \n", - "\n", - " index_name index_id \n", - "0 af20e88224165cf5ea4fe06f0aae63ca 4 \n", - "1 af20e88224165cf5ea4fe06f0aae63ca 3 \n", - "2 af20e88224165cf5ea4fe06f0aae63ca 7 \n", - "3 af20e88224165cf5ea4fe06f0aae63ca 0 \n", - "4 af20e88224165cf5ea4fe06f0aae63ca 13 \n", - "5 af20e88224165cf5ea4fe06f0aae63ca 10 \n", - "6 af20e88224165cf5ea4fe06f0aae63ca 6 \n", - "7 af20e88224165cf5ea4fe06f0aae63ca 12 \n", - "8 af20e88224165cf5ea4fe06f0aae63ca 8 \n", - "9 af20e88224165cf5ea4fe06f0aae63ca 2 " - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "global_search_streaming(\n", - " index_name=index_name, query=\"Summarize the main topics of this data\"\n", - ")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Local Search\n", - "\n", - "Local search queries are best suited for narrow-focused questions that require an understanding of specific entities mentioned in the documents (e.g. What are the healing properties of chamomile?)" - ] - }, - { - "cell_type": "code", - "execution_count": 47, - "metadata": {}, - "outputs": [], - "source": [ - "def local_search(index_name: str | list[str], query: str) -> requests.Response:\n", - " \"\"\"Run a local query over the knowledge graph(s) associated with one or more indexes\"\"\"\n", - " url = apim_url + \"/query/local\"\n", - " request = {\"index_name\": index_name, \"query\": query}\n", - " return requests.post(url, json=request, headers=headers)" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "# Overview of Primary Actors in Arizona and Alaska Communities\n", - "\n", - "## Arizona's Key Entities\n", - "\n", - "### Educational Institutions\n", - "- **University of Arizona and Arizona State University**: These are central to Arizona's higher education, providing academic programs and contributing to intellectual and economic development [Data: Entities (11, 12); Relationships (2, 3)].\n", - "- **Northern Arizona University**: Serves additional communities within Arizona, complementing the state's educational landscape [Data: Relationships (62)].\n", - "\n", - "### Native American Nations\n", - "- **Navajo Nation**: The largest Native American tribe in the U.S., with significant territory and cultural-political influence in Arizona [Data: Entities (15); Relationships (4)].\n", - "\n", - "### Religious Organizations\n", - "- **Roman Catholic Church and Church of Jesus Christ of Latter-day Saints**: Reflect the state's religious diversity and potential influence on local communities and politics [Data: Entities (16, 17); Relationships (5, 6)].\n", - "\n", - "### Political Figures and Parties\n", - "- **Barry Goldwater and Gabby Giffords**: Influential figures in Arizona's political history [Data: Entities (13, 46); Relationships (7, 55, 56)].\n", - "- **Democratic Party**: Dominated Arizona politics from statehood through the late 1940s [Data: Entities (89); Relationships (55)].\n", - "\n", - "### Economic Contributors\n", - "- **Tourism**: Dude ranches and resorts contribute to Arizona's appeal [Data: Entities (22, 23, 24, 25, 26, 27, 38, 39); Relationships (11, 12, 13, 14, 15, 16, 20, 21)].\n", - "- **Retirement Communities**: Sun City and Green Valley play a role in the state's demographic and economic profile [Data: Entities (38); Relationships (20)].\n", - "\n", - "## Alaska's Key Entities\n", - "\n", - "### Agricultural Sector\n", - "- **Alaskan Agriculture**: Experiencing growth in market gardeners, small farms, and farmers' markets [Data: Entities (209); Relationships (157, 158)].\n", - "\n", - "### Cultural Institutions\n", - "- **Alaska Native Heritage Center**: Celebrates the heritage of Alaska's cultural groups [Data: Entities (214); Relationships (159)].\n", - "- **Anchorage Symphony Orchestra**: The most prominent orchestra in Alaska [Data: Entities (218); Relationships (160)].\n", - "\n", - "### Healthcare Facilities\n", - "- **Southeast Alaska Regional Health Consortium**: Runs healthcare facilities across 27 communities in Southeast Alaska [Data: Entities (224); Relationships (162)].\n", - "\n", - "### Education\n", - "- **Alaska Department of Education and Early Development**: Administers many school districts in Alaska [Data: Entities (225); Relationships (163)].\n", - "\n", - "### Religious Organizations\n", - "- **Russian Orthodox Church**: Played a role in integrating Russian immigrants into Alaskan society [Data: Entities (192); Relationships (122)].\n", - "\n", - "### Community Centers\n", - "- **Islamic Community Center of Anchorage**: Began efforts to construct the first mosque in Anchorage [Data: Entities (194); Relationships (136)].\n", - "\n", - "These entities and individuals play significant roles in shaping the cultural, educational, political, and economic landscapes of their respective states. They are the primary actors within the communities of Arizona and Alaska, influencing various aspects of life from policy to local traditions and economic development.\n", - "CPU times: user 14 ms, sys: 3.52 ms, total: 17.5 ms\n", - "Wall time: 40.5 s\n" - ] - }, - { - "data": { - "text/plain": [ - "{'reports': [{'id': '0',\n", - " 'title': 'Arizona: A Mosaic of Communities, History, and Politics',\n", - " 'content': \"# Arizona: A Mosaic of Communities, History, and Politics\\n\\nArizona is a state with a rich tapestry of communities, historical events, and political entities. Its entities range from major public universities and Native American nations to political figures and historical landmarks. The relationships between these entities highlight the state's diverse cultural, educational, and political landscape.\\n\\n## Arizona's Educational Institutions as Pillars of the Community\\n\\nArizona's major public universities, the University of Arizona and Arizona State University, are central to the state's higher education and research. They provide academic programs and opportunities to a large student body, contributing to the state's intellectual and economic development [Data: Entities (11, 12); Relationships (2, 3)]. Northern Arizona University further complements the state's educational landscape, serving additional communities within Arizona [Data: Relationships (62)].\\n\\n## The Navajo Nation's Unique Cultural and Political Presence\\n\\nThe Navajo Nation, as the largest Native American tribe in the U.S., holds a significant territory predominantly in Arizona. It has a unique cultural and political influence, including the observance of Daylight Saving Time, which differs from the rest of Arizona [Data: Entities (15); Relationships (4)].\\n\\n## Religious Organizations and Their Influence in Arizona\\n\\nThe Roman Catholic Church and the Church of Jesus Christ of Latter-day Saints have substantial followings in Arizona. Their presence reflects the state's religious diversity and the potential influence these organizations may have on local communities and politics [Data: Entities (16, 17); Relationships (5, 6)].\\n\\n## Arizona's Political Landscape Shaped by Key Figures and Parties\\n\\nArizona's political history is marked by influential figures such as Barry Goldwater and Gabby Giffords, as well as the shifting dominance between the Democratic and Republican parties. These dynamics have shaped the state's political discourse and policies over the years [Data: Entities (13, 46); Relationships (7, 55, 56)].\\n\\n## Tourism and Retirement Communities as Economic Contributors\\n\\nArizona's economy benefits from tourism, with dude ranches and resorts contributing to the state's appeal. Retirement communities like Sun City and Green Valley also play a role in the state's demographic and economic profile [Data: Entities (22, 23, 24, 25, 26, 27, 38, 39); Relationships (11, 12, 13, 14, 15, 16, 20, 21)].\\n\\n## Arizona's Role in National and International Relations\\n\\nArizona's geographical position adjacent to other U.S. states and Mexican states like Sonora and Baja California facilitates cross-border cultural and economic exchanges. This positioning underscores the state's role in broader national and international contexts [Data: Entities (3, 4, 5, 6, 53, 54); Relationships (27, 28, 29, 30, 31, 32, 33)].\\n\\n## Historical Landmarks and Events Commemorating Arizona's Past\\n\\nHistorical landmarks such as the USS Arizona and the Barringer Meteorite Crater, along with events like the Great Depression and World War II internment camps, are part of Arizona's complex history. These sites and events are reminders of the state's past and its impact on the present [Data: Entities (21, 47, 52); Relationships (10, 17, 18, 25, 26)].\",\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '0'}],\n", - " 'entities': [{'id': '209',\n", - " 'entity': 'ALASKAN AGRICULTURE',\n", - " 'description': \"Sector experiencing growth in market gardeners, small farms, and farmers' markets\",\n", - " 'number of relationships': '2',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '209'},\n", - " {'id': '212',\n", - " 'entity': 'NORTH PACIFIC',\n", - " 'description': 'Location of primary fisheries in Alaska',\n", - " 'number of relationships': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '212'},\n", - " {'id': '38',\n", - " 'entity': 'SUN CITY',\n", - " 'description': 'A retirement community established by developer Del Webb in 1960>',\n", - " 'number of relationships': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '38'},\n", - " {'id': '100',\n", - " 'entity': 'JEROME',\n", - " 'description': 'Known as a budding artist colony',\n", - " 'number of relationships': '0',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '100'},\n", - " {'id': '153',\n", - " 'entity': 'ALASKA STATEHOOD COMMITTEE',\n", - " 'description': \"Committee that played a role in the movement for Alaska's statehood\",\n", - " 'number of relationships': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '153'},\n", - " {'id': '105',\n", - " 'entity': 'JUST ONE OF THE GUYS',\n", - " 'description': 'A major Hollywood film made in Arizona',\n", - " 'number of relationships': '0',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '105'},\n", - " {'id': '192',\n", - " 'entity': 'RUSSIAN ORTHODOX CHURCH',\n", - " 'description': 'The first Russian Orthodox Church established in Kodiak, Alaska, which played a role in integrating Russian immigrants into society',\n", - " 'number of relationships': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '192'},\n", - " {'id': '253',\n", - " 'entity': 'MATANUSKA-SUSITNA BOROUGH',\n", - " 'description': 'Region in Alaska with strong Republican showing',\n", - " 'number of relationships': '0',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '253'},\n", - " {'id': '101',\n", - " 'entity': 'TUBAC',\n", - " 'description': 'Known as a budding artist colony',\n", - " 'number of relationships': '0',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '101'},\n", - " {'id': '89',\n", - " 'entity': 'DEMOCRATIC PARTY',\n", - " 'description': 'Political party that primarily dominated Arizona from statehood through the late 1940s',\n", - " 'number of relationships': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '89'},\n", - " {'id': '224',\n", - " 'entity': 'SOUTHEAST ALASKA REGIONAL HEALTH CONSORTIUM',\n", - " 'description': 'Runs healthcare facilities across 27 communities in Southeast Alaska',\n", - " 'number of relationships': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '224'},\n", - " {'id': '109',\n", - " 'entity': 'THE BANGER SISTERS',\n", - " 'description': 'A major Hollywood film made in Arizona',\n", - " 'number of relationships': '0',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '109'},\n", - " {'id': '218',\n", - " 'entity': 'ANCHORAGE SYMPHONY ORCHESTRA',\n", - " 'description': 'The most prominent orchestra in Alaska',\n", - " 'number of relationships': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '218'},\n", - " {'id': '111',\n", - " 'entity': 'RAISING ARIZONA',\n", - " 'description': 'A major Hollywood film made in Arizona',\n", - " 'number of relationships': '0',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '111'},\n", - " {'id': '69',\n", - " 'entity': 'CATHOLICS',\n", - " 'description': 'Catholics in Arizona, with a significant number of adherents',\n", - " 'number of relationships': '0',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '69'},\n", - " {'id': '214',\n", - " 'entity': 'ALASKA NATIVE HERITAGE CENTER',\n", - " 'description': \"Cultural center celebrating the heritage of Alaska's cultural groups\",\n", - " 'number of relationships': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '214'},\n", - " {'id': '225',\n", - " 'entity': 'ALASKA DEPARTMENT OF EDUCATION AND EARLY DEVELOPMENT',\n", - " 'description': 'Administers many school districts in Alaska',\n", - " 'number of relationships': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '225'},\n", - " {'id': '202',\n", - " 'entity': 'MATANUSKA VALLEY',\n", - " 'description': 'A region in Alaska known for its agricultural activity',\n", - " 'number of relationships': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '202'},\n", - " {'id': '194',\n", - " 'entity': 'ISLAMIC COMMUNITY CENTER OF ANCHORAGE',\n", - " 'description': 'An organization that began efforts to construct the first mosque in Anchorage, Alaska',\n", - " 'number of relationships': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '194'},\n", - " {'id': '104',\n", - " 'entity': 'WAITING TO EXHALE',\n", - " 'description': 'A major Hollywood film made in Arizona',\n", - " 'number of relationships': '0',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '104'}],\n", - " 'relationships': [{'id': '20',\n", - " 'source': 'ARIZONA',\n", - " 'target': 'SUN CITY',\n", - " 'description': 'Sun City is a retirement community developed in Arizona',\n", - " 'weight': '1.0',\n", - " 'rank': '66',\n", - " 'links': '2',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '20'},\n", - " {'id': '55',\n", - " 'source': 'ARIZONA',\n", - " 'target': 'DEMOCRATIC PARTY',\n", - " 'description': 'The Democratic Party was the dominant party in Arizona from statehood through the late 1940s',\n", - " 'weight': '1.0',\n", - " 'rank': '66',\n", - " 'links': '2',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '55'},\n", - " {'id': '122',\n", - " 'source': 'ALASKA',\n", - " 'target': 'RUSSIAN ORTHODOX CHURCH',\n", - " 'description': 'The Russian Orthodox Church was established in Kodiak, Alaska and contributed to the integration of Russian immigrants',\n", - " 'weight': '1.0',\n", - " 'rank': '40',\n", - " 'links': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '122'},\n", - " {'id': '136',\n", - " 'source': 'ANCHORAGE',\n", - " 'target': 'ISLAMIC COMMUNITY CENTER OF ANCHORAGE',\n", - " 'description': 'The Islamic Community Center of Anchorage is constructing the first mosque in Anchorage',\n", - " 'weight': '1.0',\n", - " 'rank': '9',\n", - " 'links': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '136'},\n", - " {'id': '152',\n", - " 'source': 'MATANUSKA VALLEY',\n", - " 'target': 'ALASKA STATE FAIR',\n", - " 'description': 'The Matanuska Valley is a region known for agriculture and is near where the Alaska State Fair is held',\n", - " 'weight': '1.0',\n", - " 'rank': '4',\n", - " 'links': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '152'},\n", - " {'id': '158',\n", - " 'source': 'ALASKAN AGRICULTURE',\n", - " 'target': 'ALASKA GROWN',\n", - " 'description': \"'Alaska Grown' is a slogan representing the agricultural sector in Alaska\",\n", - " 'weight': '1.0',\n", - " 'rank': '3',\n", - " 'links': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '158'},\n", - " {'id': '157',\n", - " 'source': 'HAMMOND',\n", - " 'target': 'ALASKAN AGRICULTURE',\n", - " 'description': 'Hammond spearheaded a state program that contributed to the development of Alaskan agriculture',\n", - " 'weight': '1.0',\n", - " 'rank': '3',\n", - " 'links': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '157'},\n", - " {'id': '140',\n", - " 'source': 'ALASKA STATEHOOD COMMITTEE',\n", - " 'target': 'U.S. CONGRESS',\n", - " 'description': \"The Alaska Statehood Committee was involved in the process that led to the U.S. Congress approving Alaska's statehood\",\n", - " 'weight': '1.0',\n", - " 'rank': '2',\n", - " 'links': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '140'},\n", - " {'id': '159',\n", - " 'source': 'ALASKA NATIVE HERITAGE CENTER',\n", - " 'target': 'ALASKA NATIVE ARTS FOUNDATION',\n", - " 'description': 'Both organizations are involved in promoting and celebrating Alaska Native culture and arts',\n", - " 'weight': '1.0',\n", - " 'rank': '2',\n", - " 'links': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '159'},\n", - " {'id': '160',\n", - " 'source': 'ANCHORAGE SYMPHONY ORCHESTRA',\n", - " 'target': \"ALASKA'S FLAG\",\n", - " 'description': \"The Anchorage Symphony Orchestra may perform 'Alaska's Flag', the state song, at events\",\n", - " 'weight': '1.0',\n", - " 'rank': '2',\n", - " 'links': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '160'},\n", - " {'id': '163',\n", - " 'source': 'ALASKA DEPARTMENT OF EDUCATION AND EARLY DEVELOPMENT',\n", - " 'target': 'UNIVERSITY OF ALASKA ANCHORAGE',\n", - " 'description': 'The department oversees education and may work with universities like the University of Alaska Anchorage',\n", - " 'weight': '1.0',\n", - " 'rank': '2',\n", - " 'links': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '163'},\n", - " {'id': '145',\n", - " 'source': 'BERING SEA',\n", - " 'target': 'NORTH PACIFIC',\n", - " 'description': 'Both are locations of primary fisheries in Alaska',\n", - " 'weight': '1.0',\n", - " 'rank': '2',\n", - " 'links': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '145'},\n", - " {'id': '162',\n", - " 'source': 'PROVIDENCE ALASKA MEDICAL CENTER',\n", - " 'target': 'SOUTHEAST ALASKA REGIONAL HEALTH CONSORTIUM',\n", - " 'description': 'Both provide healthcare services in Alaska',\n", - " 'weight': '1.0',\n", - " 'rank': '2',\n", - " 'links': '1',\n", - " 'in_context': True,\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '162'}],\n", - " 'claims': [],\n", - " 'sources': [{'id': '10',\n", - " 'text': ') southeast of Fairbanks, with a sizable concentration of farms growing agronomic crops; these farms mostly lie north and east of Fort Greely. This area was largely set aside and developed under a state program spearheaded by Hammond during his second term as governor. Delta-area crops consist predominantly of barley and hay. West of Fairbanks lies another concentration of small farms catering to restaurants, the hotel and tourist industry, and community-supported agriculture.\\nAlaskan agriculture has experienced a surge in growth of market gardeners, small farms and farmers\\' markets in recent years, with the highest percentage increase (46%) in the nation in growth in farmers\\' markets in 2011, compared to 17% nationwide. The peony industry has also taken off, as the growing season allows farmers to harvest during a gap in supply elsewhere in the world, thereby filling a niche in the flower market.\\n\\nAlaska, with no counties, lacks county fairs. However, a small assortment of state and local fairs (with the Alaska State Fair in Palmer the largest), are held mostly in the late summer. The fairs are mostly located in communities with historic or current agricultural activity, and feature local farmers exhibiting produce in addition to more high-profile commercial activities such as carnival rides, concerts and food. \"Alaska Grown\" is used as an agricultural slogan.\\nAlaska has an abundance of seafood, with the primary fisheries in the Bering Sea and the North Pacific. Seafood is one of the few food items that is often cheaper within the state than outside it. Many Alaskans take advantage of salmon seasons to harvest portions of their household diet while fishing for subsistence, as well as sport. This includes fish taken by hook, net or wheel.Hunting for subsistence, primarily caribou, moose, and Dall sheep is still common in the state, particularly in remote Bush communities. An example of a traditional native food is Akutaq, the Eskimo ice cream, which can consist of reindeer fat, seal oil, dried fish meat and local berries.\\nAlaska\\'s reindeer herding is concentrated on Seward Peninsula, where wild caribou can be prevented from mingling and migrating with the domesticated reindeer.Most food in Alaska is transported into the state from \"Outside\" (the other 49 US states), and shipping costs make food in the cities relatively expensive. In rural areas, subsistence hunting and gathering is an essential activity because imported food is prohibitively expensive. Although most small towns and villages in Alaska lie along the coastline, the cost of importing food to remote villages can be high, because of the terrain and difficult road conditions, which change dramatically, due to varying climate and precipitation changes. The cost of transport can reach as high as 50¢ per pound ($1.10/kg) or more in some remote areas, during the most difficult times, if these locations can be reached at all during such inclement weather and terrain conditions. The cost of delivering a 1 US gallon (3.8 L) of milk is about $3.50 in many villages where per capita income can be $20,000 or less. Fuel cost per gallon is routinely twenty to thirty cents higher than the contiguous United States average, with only Hawaii having higher prices.\\n\\n\\n== Culture ==\\n\\nSome of Alaska\\'s popular annual events are the Iditarod Trail Sled Dog Race from Anchorage to Nome, World Ice Art Championships in Fairbanks, the Blueberry Festival and Alaska Hummingbird Festival in Ketchikan, the Sitka Whale Fest, and the Stikine River Garnet Fest in Wrangell. The Stikine River attracts the largest springtime concentration of American bald eagles in the world.\\nThe Alaska Native Heritage Center celebrates the rich heritage of Alaska\\'s 11 cultural groups. Their purpose is to encourage cross-cultural exchanges among all people and enhance self-esteem among Native people. The Alaska Native Arts Foundation promotes and markets Native art from all regions and cultures in the State, using the internet.\\n\\n\\n=== Music ===\\n\\nInfluences on music in Alaska include the traditional music of Alaska Natives as well as folk music brought by later immigrants from Russia and Europe. Prominent musicians from Alaska include singer Jewel, traditional Aleut flautist Mary Youngblood, folk singer-songwriter Libby Roderick, Christian music singer-songwriter Lincoln Brewster, metal/post hardcore band 36 Crazyfists and the groups Pamyua and Portugal. The Man.\\nThere are many established music festivals in Alaska, including the Alaska Folk Festival, the Fairbanks Summer Arts Festival the Anchorage Folk Festival, the Athabascan Old-Time Fiddling Festival, the Sitka Jazz Festival, and the Sitka Summer Music Festival. The most prominent orchestra in Alaska is the Anchorage Symphony Orchestra, though the Fairbanks Symphony Orchestra and Juneau Symphony are also notable. The Anchorage Opera is currently the state\\'s only professional opera company, though there are several volunteer and semi-professional organizations in the state as well.\\nThe official state song of Alaska is \"Alaska\\'s Flag\", which was adopted in 1955; it celebrates the flag of Alaska.\\n\\n\\n=== Alaska on film and television ===\\n\\nThe 1983 Disney movie Never Cry Wolf was at least partially shot in Alaska. The 1991 film White Fang, based on Jack London\\'s 1906 novel and starring Ethan Hawke, was filmed in and around Haines. Steven Seagal\\'s 1994 On Deadly Ground, starring Michael Caine, was filmed in part at the Worthington Glacier near Valdez.Many reality television shows are filmed in Alaska. In 2011, the Anchorage Daily News found ten set in the state.\\n\\n\\n=== Sports ===\\n\\n\\n== Public health and public safety ==\\n\\nThe Alaska State Troopers are Alaska\\'s statewide police force. They have a long and storied history, but were not an official organization until 1941. Before the force was officially organized, law enforcement in Alaska was handled by various federal agencies. Larger towns usually have their own local police and some villages rely on \"Public Safety Officers\" who have police training but do not carry firearms. In much of the state, the troopers serve as the only police force available. In addition to enforcing traffic and criminal law, wildlife Troopers enforce hunting and fishing regulations. Due to the varied terrain and wide scope of the Troopers\\' duties, they employ a wide variety of land, air, and water patrol vehicles.\\nMany rural communities in Alaska are considered \"dry\", having outlawed the importation of alcoholic beverages. Suicide rates for rural residents are higher than urban.Domestic abuse and other violent crimes are also at high levels in the state; this is in part linked to alcohol abuse. Alaska has the highest rate of sexual assault in the nation, especially in rural areas. The average age of sexually assaulted victims is 16 years old. In four out of five cases, the suspects were relatives, friends or acquaintances.\\n\\n\\n=== Health insurance ===\\nAs of 2022, CVS Health and Premera account for 47% and 46% of private health insurance, respectively. Premera and Moda Health offer insurance on the federally-run Affordable Care Exchange.\\n\\n\\n=== Healthcare facilities ===\\n\\nProvidence Alaska Medical Center in Anchorage is the largest hospital in the state as of 2021; Anchorage also hosts Alaska Regional Hospital and Alaska Native Medical Center.\\nAlaska\\'s other major cities such as Fairbanks and Juneau also have local hospitals. In Southeast Alaska, Southeast Alaska Regional Health Consortium, runs healthcare facilities across 27 communities as of 2022, including hospitals in Sitka and Wrangell; although it originally served Native Americans only, it has expanded access and combined with other local facilities over time.\\n\\n\\n== Education ==\\nThe Alaska Department of Education and Early Development administers many school districts in Alaska. In addition, the state operates a boarding school, Mt. Edgecumbe High School in Sitka, and provides partial funding for other boarding schools, including Nenana Student Living Center in Nenana and The Galena Interior Learning Academy in Galena.There are more than a dozen colleges and universities in Alaska. Accredited universities in Alaska include the University of Alaska Anchorage, University of Alaska Fairbanks, University of Alaska Southeast, and Alaska Pacific University. Alaska is the only state that has no collegiate athletic programs that are members of NCAA Division I, although both Alaska-Fairbanks and Alaska-Anchorage maintain single sport membership in Division I for men\\'s ice hockey.\\nThe Alaska Department of Labor and Workforce Development operates AVTEC, Alaska\\'s Institute of Technology. Campuses in Seward and Anchorage offer one-week to 11-month training programs in areas as diverse as Information Technology, Welding, Nursing, and Mechanics.\\nAlaska has had a problem with a \"brain drain\". Many of its young people, including most of the highest academic achievers, leave the state after high school graduation and do not return. As of 2013, Alaska did not have a law school or medical school. The University of Alaska has attempted to combat this by offering partial four-year scholarships to the top 10% of Alaska high school graduates, via the Alaska Scholars Program.Beginning in 1998, schools in rural Alaska must have at least 10 students to retain funding from the state, and campuses not meeting the number close. This was due to the loss in oil revenues that previously propped up smaller rural schools. In 2015, there was a proposal to raise that minimum to 25, but legislators in the state largely did not agree.\\n\\n\\n== Transportation ==\\n\\n\\n=== Roads ===\\n\\nAlaska has few road connections compared to the rest of the U.S. The state\\'s road system, covering a relatively small area of the state, linking the central population centers and the Alaska Highway, the principal route out of the state through Canada. The state capital, Juneau, is not accessible by road, with access only being through ferry or flight; this has spurred debate over decades about moving the capital to a city on the road system, or building a road connection from Haines. The western part of Alaska has no road system connecting the communities with the rest of Alaska.\\nThe Interstate Highways in Alaska consists of a total of 1,082 miles (1,741 km). One unique feature of the Alaska Highway system is the Anton Anderson Memorial Tunnel, an active Alaska Railroad tunnel recently upgraded to provide a paved roadway link with the isolated community of Whittier on Prince William Sound to the Seward Highway about 50 miles (80 km) southeast of Anchorage at Portage. At 2.5 miles (4.0 km), the tunnel was the longest road tunnel in North America until 2007. The tunnel is the longest combination road and rail tunnel in North America.\\n\\n\\t\\t\\t\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t\\t\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t\\t\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t\\t\\n\\t\\t\\t\\n\\t\\t\\n\\n\\n=== Rail ===\\nBuilt around 1915, the Alaska Railroad (ARR) played a key role in the development of Alaska through the 20th century. It links shipping lanes on the North Pacific with Interior Alaska with tracks that run from Seward by way of South Central Alaska, passing through Anchorage, Eklutna, Wasilla, Talkeetna, Denali, and Fairbanks, with spurs to Whittier, Palmer and North Pole. The cities, towns, villages, and region served by ARR tracks are known statewide as \"The Railbelt\". In recent years, the ever-improving paved highway system began to eclipse the railroad\\'s importance in Alaska\\'s economy.\\nThe railroad played a vital role in Alaska\\'s development, moving freight into Alaska while transporting natural resources southward, such as coal from the Usibelli coal mine near Healy to Seward and gravel from the Matanuska Valley to Anchorage. It is well known for its summertime tour passenger service.\\nThe Alaska Railroad was one of the last railroads in North America to use cabooses in regular service and still uses them on some gravel trains. It continues to offer one of the last flag stop routes in the country. A stretch of about 60 miles (100 km) of track along an area north of Talkeetna remains inaccessible by road; the railroad provides the only transportation to rural homes and cabins in the area. Until construction of the Parks Highway in the 197',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '8767ef9e72aafc448a84cc850482cf32'},\n", - " {'id': '1',\n", - " 'text': ', just west of Nogales, an Indian War battle had occurred, considered the last engagement in the American Indian Wars, which lasted from 1775 to 1918. U.S. soldiers stationed on the border confronted Yaqui Indians who were using Arizona as a base to raid the nearby Mexican settlements, as part of their wars against Mexico.Arizona became a U.S. state on February 14, 1912, coinciding with Valentine\\'s Day. Arizona was the 48th state admitted to the U.S. and the last of the contiguous states to be admitted.\\nCotton farming and copper mining, two of Arizona\\'s most important statewide industries, suffered heavily during the Great Depression. But during the 1920s and even the 1930s, tourism began to develop as the important Arizonan industry it is today. Dude ranches, such as the K L Bar and Remuda in Wickenburg, along with the Flying V and Tanque Verde in Tucson, gave tourists the chance to take part in the flavor and activities of the \"Old West\". Several upscale hotels and resorts opened during this period, some of which are still top tourist draws. They include the Arizona Biltmore Hotel in central Phoenix (opened 1929) and the Wigwam Resort on the west side of the Phoenix area (opened 1936).Arizona was the site of German prisoner of war camps during World War II and Japanese American internment camps. Because of wartime fears of a Japanese invasion of the U.S. West Coast (which in fact materialized in the Aleutian Islands Campaign in June 1942), from 1942 to 1945, persons of Japanese descent were forced to reside in internment camps built in the interior of the country. Many lost their homes and businesses. The camps were abolished after World War II.The Phoenix-area German P.O.W. site was purchased after the war by the Maytag family (of major home appliance fame). It was developed as the site of the Phoenix Zoo. A Japanese-American internment camp was on Mount Lemmon, just outside the state\\'s southeastern city of Tucson. Another POW camp was near the Gila River in eastern Yuma County. Arizona was also home to the Phoenix Indian School, one of several federal Indian boarding schools designed to assimilate Native American children into mainstream European-American culture. Children were often enrolled in these schools against the wishes of their parents and families. Attempts to suppress native identities included forcing the children to cut their hair, to take and use English names, to speak only English, and to practice Christianity rather than their native religions.Numerous Native Americans from Arizona fought for the United States during World War II. Their experiences resulted in a rising activism in the postwar years to achieve better treatment and civil rights after their return to the state. After Maricopa County did not allow them to register to vote, in 1948 veteran Frank Harrison and Harry Austin, of the Mojave-Apache Tribe at Fort McDowell Indian Reservation, brought a legal suit, Harrison and Austin v. Laveen, to challenge this exclusion. The Arizona Supreme Court ruled in their favor.Arizona\\'s population grew tremendously with residential and business development after World War II, aided by the widespread use of air conditioning, which made the intensely hot summers more comfortable. According to the Arizona Blue Book (published by the Arizona Secretary of State\\'s office each year), the state population in 1910 was 294,353. By 1970, it was 1,752,122. The percentage growth each decade averaged about 20% in the earlier decades, and about 60% each decade thereafter.In the 1960s, retirement communities were developed. These age-restricted subdivisions catered exclusively to the needs of senior citizens and attracted many retirees who wanted to escape the harsh winters of the Midwest and the Northeast. Sun City, established by developer Del Webb and opened in 1960, was one of the first such communities. Green Valley, south of Tucson, was another such community, designed as a retirement subdivision for Arizona\\'s teachers. Many senior citizens from across the United States and Canada come to Arizona each winter and stay only during the winter months; they are referred to as snowbirds.In March 2000, Arizona was the site of the first legally binding election ever held over the internet to nominate a candidate for public office. In the 2000 Arizona Democratic Primary, under worldwide attention, Al Gore defeated Bill Bradley. Voter turnout in this state primary increased more than 500% over the 1996 primary.\\nIn the 21st century, Arizona has frequently garnered national attention for its efforts to quell illegal immigration into the state. In 2004, voters passed Proposition 200, requiring proof of citizenship to register to vote. The Supreme Court of the United States struck this restriction down in 2013. In 2010, Arizona enacted SB 1070 which required all immigrants to carry immigration papers at all times, but the Supreme Court also invalidated parts of this law in Arizona v. United States in 2012.On January 8, 2011, a gunman shot congresswoman Gabby Giffords and 18 others at a gathering in Tucson. Giffords was critically wounded. The incident sparked national attention regarding incendiary political rhetoric.Three ships named USS Arizona have been christened in honor of the state, although only USS Arizona (BB-39) was so named after statehood was achieved.\\n\\n\\n== Geography ==\\n\\nArizona is in the Southwestern United States as one of the Four Corners states. Arizona is the sixth largest state by area, ranked after New Mexico and before Nevada. Of the state\\'s 113,998 square miles (295,000 km2), approximately 15% is privately owned. The remaining area is public forest and parkland, state trust land and Native American reservations. There are 24 National Park Service maintained sites in Arizona, including the three national parks of Grand Canyon National Park, Saguaro National Park, and the Petrified Forest National Park.Arizona is well known for its desert Basin and Range region in the state\\'s southern portions, which is rich in a landscape of xerophyte plants such as the cactus. This region\\'s topography was shaped by prehistoric volcanism, followed by the cooling-off and related subsidence. Its climate has exceptionally hot summers and mild winters. The state is less well known for its pine-covered north-central portion of the high country of the Colorado Plateau (see Arizona Mountains forests).\\nLike other states of the Southwest United States, Arizona is marked by high mountains, the Colorado plateau, and mesas. Despite the state\\'s aridity, 27% of Arizona is forest, a percentage comparable to modern-day Romania or Greece. The world\\'s largest stand of ponderosa pine trees is in Arizona.The Mogollon Rim (/ ˌmoʊ gəˈyoʊn /), a 1,998-foot (609 m) escarpment, cuts across the state\\'s central section and marks the southwestern edge of the Colorado Plateau. In 2002, this was an area of the Rodeo–Chediski Fire, the worst fire in state history until 2011.\\nLocated in northern Arizona, the Grand Canyon is a colorful, deep, steep-sided gorge, carved by the Colorado River. The canyon is one of the Seven Natural Wonders of the World and is largely contained in the Grand Canyon National Park – one of the first national parks in the United States. President Theodore Roosevelt was a major proponent of designating the Grand Canyon area as a National Park, often visiting to hunt mountain lion and enjoy the scenery. The canyon was created by the Colorado River cutting a channel over millions of years, and is about 277 miles (446 km) long, ranges in width from 4 to 18 miles (6 to 29 km) and attains a depth of more than 1 mile (1.6 km). Nearly two billion years of the Earth\\'s history have been exposed as the Colorado River and its tributaries cut through layer after layer of sediment as the Colorado Plateau uplifted.\\nArizona is home to one of the most well-preserved meteorite impact sites in the world. Created around 50,000 years ago, the Barringer Meteorite Crater (better known simply as \"Meteor Crater\") is a gigantic hole in the middle of the high plains of the Colorado Plateau, about 25 miles (40 km) west of Winslow. A rim of smashed and jumbled boulders, some of them the size of small houses, rises 150 feet (46 m) above the level of the surrounding plain. The crater itself is nearly a mile (1.6 kilometers) wide and 570 feet (170 m) deep.\\nArizona is one of two U.S. states, along with Hawaii, that does not observe Daylight Saving Time, though the large Navajo Nation in the state\\'s northeastern region does.\\n\\n\\n=== Adjacent states ===\\nUtah (north)\\nColorado (northeast)\\nNevada (northwest)\\nSonora, Mexico (south)\\nBaja California, Mexico (southwest)\\nNew Mexico (east)\\nCalifornia (west)\\n\\n\\n== Climate ==\\n\\nDue to its large area and variations in elevation, the state has a wide variety of localized climate conditions. In the lower elevations the climate is primarily desert, with mild winters and extremely hot summers. Typically, from late fall to early spring, the weather is mild, averaging a minimum of 60 °F (16 °C). November through February are the coldest months, with temperatures typically ranging from 40 to 75 °F (4 to 24 °C), with occasional frosts.About midway through February, the temperatures start to rise, with warm days, and cool, breezy nights. The summer months of June through September bring a dry heat from 90 to 120 °F (32 to 49 °C), with occasional high temperatures exceeding 125 °F (52 °C) having been observed in the desert area. Arizona\\'s all-time record high is 128 °F (53 °C) recorded at Lake Havasu City on June 29, 1994, and July 5, 2007; the all-time record low of −40 °F (−40 °C) was recorded at Hawley Lake on January 7, 1971.Due to the primarily dry climate, large diurnal temperature variations occur in less-developed areas of the desert above 2,500 ft (760 m). The swings can be as large as 83 °F (46 °C) in the summer months. In the state\\'s urban centers, the effects of local warming result in much higher measured night-time lows than in the recent past.\\nArizona has an average annual rainfall of 12.7 in (323 mm), which comes during two rainy seasons, with cold fronts coming from the Pacific Ocean during the winter and a monsoon in the summer. The monsoon season occurs toward the end of summer. In July or August, the dewpoint rises dramatically for a brief period. During this time, the air contains large amounts of water vapor. Dewpoints as high as 81 °F (27 °C) have been recorded during the Phoenix monsoon season. This hot moisture brings lightning, thunderstorms, wind, and torrential, if usually brief, downpours. These downpours often cause flash floods, which can turn deadly. In an attempt to deter drivers from crossing flooding streams, the Arizona Legislature enacted the Stupid Motorist Law. It is rare for tornadoes or hurricanes to occur in Arizona.\\nArizona\\'s northern third is a plateau at significantly higher altitudes than the lower desert, and has an appreciably cooler climate, with cold winters and mild summers, though the climate remains semiarid to arid. Extremely cold temperatures are not unknown; cold air systems from the northern states and Canada occasionally push into the state, bringing temperatures below 0 °F (−18 °C) to the state\\'s northern parts.Indicative of the variation in climate, Arizona is the state which has both the metropolitan area with the most days over 100 °F (',\n", - " 'index_name': 'af20e88224165cf5ea4fe06f0aae63ca',\n", - " 'index_id': '6f74f3aa6337f5d03debbaf8424f68f0'}]}" - ] - }, - "execution_count": 48, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "%%time\n", - "# pass in a single index name as a string or to query across multiple indexes, set index_name=[myindex1, myindex2]\n", - "local_response = local_search(\n", - " index_name=index_name, query=\"Who are the primary actors in these communities?\"\n", - ")\n", - "# print the result and save context data in a variable\n", - "local_response_data = parse_query_response(local_response, return_context_data=True)\n", - "local_response_data" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sources\n", - "\n", - "In a query response, citations will often appear that support GraphRAG's response. API endpoints are provided to enable retrieval of the sourced documents, entities, relationships, etc.\n", - "\n", - "Multiple types of sources may be referenced in a query: Reports, Entities, Relationships, Claims, and Text Units. The API provides various endpoints to retrieve these sources for data provenance." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Get a Report" - ] - }, - { - "cell_type": "code", - "execution_count": 49, - "metadata": {}, - "outputs": [], - "source": [ - "def get_report(index_name: str, report_id: str) -> requests.Response:\n", - " \"\"\"Retrieve a report generated by GraphRAG for a specific index.\"\"\"\n", - " url = apim_url + f\"/source/report/{index_name}/{report_id}\"\n", - " return requests.get(url, headers=headers)" - ] - }, - { - "cell_type": "code", - "execution_count": 50, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "# Arizona: A Mosaic of Communities, History, and Politics\n", - "\n", - "Arizona is a state with a rich tapestry of communities, historical events, and political entities. Its entities range from major public universities and Native American nations to political figures and historical landmarks. The relationships between these entities highlight the state's diverse cultural, educational, and political landscape.\n", - "\n", - "## Arizona's Educational Institutions as Pillars of the Community\n", - "\n", - "Arizona's major public universities, the University of Arizona and Arizona State University, are central to the state's higher education and research. They provide academic programs and opportunities to a large student body, contributing to the state's intellectual and economic development [Data: Entities (11, 12); Relationships (2, 3)]. Northern Arizona University further complements the state's educational landscape, serving additional communities within Arizona [Data: Relationships (62)].\n", - "\n", - "## The Navajo Nation's Unique Cultural and Political Presence\n", - "\n", - "The Navajo Nation, as the largest Native American tribe in the U.S., holds a significant territory predominantly in Arizona. It has a unique cultural and political influence, including the observance of Daylight Saving Time, which differs from the rest of Arizona [Data: Entities (15); Relationships (4)].\n", - "\n", - "## Religious Organizations and Their Influence in Arizona\n", - "\n", - "The Roman Catholic Church and the Church of Jesus Christ of Latter-day Saints have substantial followings in Arizona. Their presence reflects the state's religious diversity and the potential influence these organizations may have on local communities and politics [Data: Entities (16, 17); Relationships (5, 6)].\n", - "\n", - "## Arizona's Political Landscape Shaped by Key Figures and Parties\n", - "\n", - "Arizona's political history is marked by influential figures such as Barry Goldwater and Gabby Giffords, as well as the shifting dominance between the Democratic and Republican parties. These dynamics have shaped the state's political discourse and policies over the years [Data: Entities (13, 46); Relationships (7, 55, 56)].\n", - "\n", - "## Tourism and Retirement Communities as Economic Contributors\n", - "\n", - "Arizona's economy benefits from tourism, with dude ranches and resorts contributing to the state's appeal. Retirement communities like Sun City and Green Valley also play a role in the state's demographic and economic profile [Data: Entities (22, 23, 24, 25, 26, 27, 38, 39); Relationships (11, 12, 13, 14, 15, 16, 20, 21)].\n", - "\n", - "## Arizona's Role in National and International Relations\n", - "\n", - "Arizona's geographical position adjacent to other U.S. states and Mexican states like Sonora and Baja California facilitates cross-border cultural and economic exchanges. This positioning underscores the state's role in broader national and international contexts [Data: Entities (3, 4, 5, 6, 53, 54); Relationships (27, 28, 29, 30, 31, 32, 33)].\n", - "\n", - "## Historical Landmarks and Events Commemorating Arizona's Past\n", - "\n", - "Historical landmarks such as the USS Arizona and the Barringer Meteorite Crater, along with events like the Great Depression and World War II internment camps, are part of Arizona's complex history. These sites and events are reminders of the state's past and its impact on the present [Data: Entities (21, 47, 52); Relationships (10, 17, 18, 25, 26)].\n" - ] - } - ], - "source": [ - "report_response = get_report(index_name, 0)\n", - "print(report_response.json()[\"text\"]) if report_response.ok else (report_response.reason, report_response.content)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Get an Entity" - ] - }, - { - "cell_type": "code", - "execution_count": 51, - "metadata": {}, - "outputs": [], - "source": [ - "def get_entity(index_name: str, entity_id: str) -> requests.Response:\n", - " \"\"\"Retrieve an entity generated by GraphRAG for a specific index.\"\"\"\n", - " url = apim_url + f\"/source/entity/{index_name}/{entity_id}\"\n", - " return requests.get(url, headers=headers)" - ] - }, - { - "cell_type": "code", - "execution_count": 52, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'name': 'ARIZONA',\n", - " 'description': \"Arizona is a U.S. state located in the Southwestern United States, known for its desert climate, as well as its forests, plateaus, and metropolitan areas that exhibit a variety of temperatures and weather patterns. It was admitted to the Union on February 14, 1912, as the 48th state and the last of the contiguous states to be incorporated. Arizona boasts a diverse economy and has a historical reliance on the 'five C's'. It is also home to the Grand Canyon National Park, one of the state's most prominent natural features. Following the 2010 census, Arizona gained a ninth seat in the House of Representatives due to redistricting, reflecting changes in its population.\",\n", - " 'text_units': ['6d0038acddcd4295e1a1d61934522e36',\n", - " '6f74f3aa6337f5d03debbaf8424f68f0',\n", - " 'a439d13bfd7279d36fb7e76363bf0699',\n", - " 'b641199b00c40165babb1bf98db5b9da',\n", - " 'd153b2ce9dee240a9106b3668aa275b6']}" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "entity_response = get_entity(index_name, 0)\n", - "entity_response.json() if entity_response.ok else (entity_response.reason, entity_response.content)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Get a Relationship" - ] - }, - { - "cell_type": "code", - "execution_count": 53, - "metadata": {}, - "outputs": [], - "source": [ - "def get_relationship(index_name: str, relationship_id: str) -> requests.Response:\n", - " \"\"\"Retrieve a relationship generated by GraphRAG for a specific index.\"\"\"\n", - " url = apim_url + f\"/source/relationship/{index_name}/{relationship_id}\"\n", - " return requests.get(url, headers=headers)" - ] - }, - { - "cell_type": "code", - "execution_count": 54, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'source': 'ARIZONA',\n", - " 'source_id': 0,\n", - " 'target': 'GRAND CANYON NATIONAL PARK',\n", - " 'target_id': 10,\n", - " 'description': 'The Grand Canyon National Park is a major natural feature and tourist attraction in Arizona',\n", - " 'text_units': ['d153b2ce9dee240a9106b3668aa275b6']}" - ] - }, - "execution_count": 54, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "relationship_response = get_relationship(index_name, 1)\n", - "relationship_response.json() if relationship_response.ok else (relationship_response.reason, relationship_response.content)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Get a Claim" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def get_claim(index_name: str, claim_id: str) -> requests.Response:\n", - " \"\"\"Retrieve a claim/covariate generated by GraphRAG for a specific index.\"\"\"\n", - " url = apim_url + f\"/source/claim/{index_name}/{claim_id}\"\n", - " return requests.get(url, headers=headers)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "claim_response = get_claim(index_name, 1)\n", - "if claim_response.ok:\n", - " pprint(claim_response.json())\n", - "else:\n", - " print(claim_response)\n", - " print(claim_response.text)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Get a Text Unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def get_text_unit(index_name: str, text_unit_id: str) -> requests.Response:\n", - " \"\"\"Retrieve a text unit generated by GraphRAG for a specific index.\"\"\"\n", - " url = apim_url + f\"/source/text/{index_name}/{text_unit_id}\"\n", - " return requests.get(url, headers=headers)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# get a text unit id from one of the previous Source endpoint results (look for 'text_units' in the response)\n", - "text_unit_id = \"\"\n", - "if not text_unit_id:\n", - " raise ValueError(\n", - " \"Must provide a text_unit_id from previous source results. Look for 'text_units' in the response.\"\n", - " )\n", - "text_unit_response = get_text_unit(index_name, text_unit_id)\n", - "if text_unit_response.ok:\n", - " print(text_unit_response.json()[\"text\"])\n", - "else:\n", - " print(text_unit_response.reason)\n", - " print(text_unit_response.content)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exploring the GraphRAG knowledge graph\n", - "The API currently provides some basic functionality to better understand the knowledge graph that was constructed during the indexing process.\n", - "\n", - "In addition, an option is available to export the graph to a graphml file which can be imported by other open source visualization software (we recommend [Gephi](https://gephi.org/)) for deeper exploration." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Basic knowledge graph statistics" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def get_graph_stats(index_name: str) -> requests.Response:\n", - " \"\"\"Get basic statistics about the knowledge graph constructed by GraphRAG.\"\"\"\n", - " url = apim_url + f\"/graph/stats/{index_name}\"\n", - " return requests.get(url, headers=headers)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "response = get_graph_stats(index_name)\n", - "print(response)\n", - "print(response.text)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Get a GraphML file" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def save_graphml_file(index_name: str, graphml_file_name: str) -> None:\n", - " \"\"\"Retrieve and save a graphml file that represents the knowledge graph.\n", - " The file is downloaded in chunks and saved to the local file system.\n", - " \"\"\"\n", - " url = apim_url + f\"/graph/graphml/{index_name}\"\n", - " if Path(graphml_file_name).suffix != \".graphml\":\n", - " raise UserWarning(f\"{graphml_file_name} must have a .graphml file extension\")\n", - " with requests.get(url, headers=headers, stream=True) as r:\n", - " r.raise_for_status()\n", - " with open(graphml_file_name, \"wb\") as f:\n", - " for chunk in r.iter_content(chunk_size=1024):\n", - " f.write(chunk)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# will save graphml file to the current local directory\n", - "save_graphml_file(index_name, \"knowledge_graph.graphml\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": ".venv", - "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.10.14" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}