svetakvsundhar commented on code in PR #27516:
URL: https://github.com/apache/beam/pull/27516#discussion_r1269676516


##########
examples/notebooks/healthcare/beam_nlp.ipynb:
##########
@@ -0,0 +1,968 @@
+{
+  "nbformat": 4,
+  "nbformat_minor": 0,
+  "metadata": {
+    "colab": {
+      "provenance": [],
+      "include_colab_link": true
+    },
+    "kernelspec": {
+      "name": "python3",
+      "display_name": "Python 3"
+    },
+    "language_info": {
+      "name": "python"
+    }
+  },
+  "cells": [
+    {
+      "cell_type": "markdown",
+      "metadata": {
+        "id": "view-in-github",
+        "colab_type": "text"
+      },
+      "source": [
+        "<a 
href=\"https://colab.research.google.com/github/apache/beam/blob/healthcarenlp/examples/notebooks/healthcare/beam_nlp.ipynb\";
 target=\"_parent\"><img 
src=\"https://colab.research.google.com/assets/colab-badge.svg\"; alt=\"Open In 
Colab\"/></a>"
+      ]
+    },
+    {
+      "cell_type": "code",
+      "source": [
+        "# @title ###### Licensed to the Apache Software Foundation (ASF), 
Version 2.0 (the \"License\")\n",
+        "\n",
+        "# Licensed to the Apache Software Foundation (ASF) under one\n",
+        "# or more contributor license agreements. See the NOTICE file\n",
+        "# distributed with this work for additional information\n",
+        "# regarding copyright ownership. The ASF licenses this file\n",
+        "# to you under the Apache License, Version 2.0 (the\n",
+        "# \"License\"); you may not use this file except in compliance\n",
+        "# with the License. You may obtain a copy of the License at\n",
+        "#\n",
+        "#   http://www.apache.org/licenses/LICENSE-2.0\n";,
+        "#\n",
+        "# Unless required by applicable law or agreed to in writing,\n",
+        "# software distributed under the License is distributed on an\n",
+        "# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n",
+        "# KIND, either express or implied. See the License for the\n",
+        "# specific language governing permissions and limitations\n",
+        "# under the License"
+      ],
+      "metadata": {
+        "id": "lBuUTzxD2mvJ"
+      },
+      "execution_count": null,
+      "outputs": []
+    },
+    {
+      "cell_type": "markdown",
+      "source": [
+        "# **Natural Language Processing Pipeline**\n",
+        "\n",
+        "**Note**: This example is used from 
[here](https://github.com/rasalt/healthcarenlp/blob/main/nlp_public.ipynb).\n",
+        "\n",
+        "\n",
+        "\n",
+        "This example demonstrates how to set up an Apache Beam pipeline that 
reads a file from [Google Cloud 
Storage](https://https://cloud.google.com/storage), and calls the [Google Cloud 
Healthcare NLP API](https://cloud.google.com/healthcare-api/docs/how-tos/nlp) 
to extract information from unstructured data. This application can be used in 
contexts such as reading scanned clinical documents and extracting structure 
from it.\n",
+        "\n",
+        "An Apache Beam pipeline is a pipeline that reads input data, 
transforms that data, and writes output data. It consists of PTransforms and 
PCollections. A PCollection represents a distributed data set that your Beam 
pipeline operates on. A PTransform represents a data processing operation, or a 
step, in your pipeline. It takes one or more PCollections as input, performs a 
processing function that you provide on the elements of that PCollection, and 
produces zero or more output PCollection objects.\n",
+        "\n",
+        "For details about Apache Beam pipelines, including PTransforms and 
PCollections, visit the [Beam Programming 
Guide](https://beam.apache.org/documentation/programming-guide/).\n",
+        "\n",
+        "You'll be able to use this notebook to explore the data in each 
PCollection."
+      ],
+      "metadata": {
+        "id": "nEUAYCTx4Ijj"
+      }
+    },
+    {
+      "cell_type": "markdown",
+      "source": [
+        "Instructions\n",
+        "1. Set the variables in the next cell based upon your project and 
preferences\n",
+        "2. The files referred to in this notebook nlpsample*.csv are in the 
format with one\n",
+        "blurb of clinical note."
+      ],
+      "metadata": {
+        "id": "ZLBB0PTG5CHw"
+      }
+    },
+    {
+      "cell_type": "code",
+      "source": [
+        "pip install apache-beam[gcp]"
+      ],
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/";
+        },
+        "id": "O7hq2sse8K4u",
+        "outputId": "c6f559a6-1419-43f2-b88d-49fedca1c686"
+      },
+      "execution_count": null,
+      "outputs": [
+        {
+          "output_type": "stream",
+          "name": "stdout",
+          "text": [
+            "Requirement already satisfied: apache-beam[gcp] in 
/usr/local/lib/python3.10/dist-packages (2.49.0)\n",
+            "Requirement already satisfied: crcmod<2.0,>=1.7 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (1.7)\n",
+            "Requirement already satisfied: orjson<4.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (3.9.2)\n",
+            "Requirement already satisfied: dill<0.3.2,>=0.3.1.1 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (0.3.1.1)\n",
+            "Requirement already satisfied: cloudpickle~=2.2.1 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2.2.1)\n",
+            "Requirement already satisfied: fastavro<2,>=0.23.6 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (1.8.0)\n",
+            "Requirement already satisfied: fasteners<1.0,>=0.3 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (0.18)\n",
+            "Requirement already satisfied: grpcio!=1.48.0,<2,>=1.33.1 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (1.56.0)\n",
+            "Requirement already satisfied: hdfs<3.0.0,>=2.1.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2.7.0)\n",
+            "Requirement already satisfied: httplib2<0.23.0,>=0.8 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (0.21.0)\n",
+            "Requirement already satisfied: numpy<1.25.0,>=1.14.3 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (1.22.4)\n",
+            "Requirement already satisfied: objsize<0.7.0,>=0.6.1 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (0.6.1)\n",
+            "Requirement already satisfied: pymongo<5.0.0,>=3.8.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (4.4.1)\n",
+            "Requirement already satisfied: proto-plus<2,>=1.7.1 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (1.22.3)\n",
+            "Requirement already satisfied: protobuf<4.24.0,>=3.20.3 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (3.20.3)\n",
+            "Requirement already satisfied: pydot<2,>=1.2.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (1.4.2)\n",
+            "Requirement already satisfied: python-dateutil<3,>=2.8.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2.8.2)\n",
+            "Requirement already satisfied: pytz>=2018.3 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2022.7.1)\n",
+            "Requirement already satisfied: regex>=2020.6.8 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2022.10.31)\n",
+            "Requirement already satisfied: requests<3.0.0,>=2.24.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2.27.1)\n",
+            "Requirement already satisfied: typing-extensions>=3.7.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (4.7.1)\n",
+            "Requirement already satisfied: zstandard<1,>=0.18.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (0.21.0)\n",
+            "Requirement already satisfied: pyarrow<12.0.0,>=3.0.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (9.0.0)\n",
+            "Requirement already satisfied: cachetools<6,>=3.1.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (5.3.1)\n",
+            "Requirement already satisfied: google-apitools<0.5.32,>=0.5.31 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (0.5.31)\n",
+            "Requirement already satisfied: google-auth<3,>=1.18.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2.17.3)\n",
+            "Requirement already satisfied: google-auth-httplib2<0.2.0,>=0.1.0 
in /usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (0.1.0)\n",
+            "Requirement already satisfied: google-cloud-datastore<3,>=2.0.0 
in /usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2.15.2)\n",
+            "Requirement already satisfied: google-cloud-pubsub<3,>=2.1.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2.18.0)\n",
+            "Requirement already satisfied: google-cloud-pubsublite<2,>=1.2.0 
in /usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (1.8.3)\n",
+            "Requirement already satisfied: google-cloud-bigquery<4,>=2.0.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (3.10.0)\n",
+            "Requirement already satisfied: 
google-cloud-bigquery-storage<3,>=2.6.3 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2.22.0)\n",
+            "Requirement already satisfied: google-cloud-core<3,>=2.0.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2.3.3)\n",
+            "Requirement already satisfied: google-cloud-bigtable<3,>=2.19.0 
in /usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2.19.0)\n",
+            "Requirement already satisfied: google-cloud-spanner<4,>=3.0.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (3.36.0)\n",
+            "Requirement already satisfied: google-cloud-dlp<4,>=3.0.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (3.12.2)\n",
+            "Requirement already satisfied: google-cloud-language<3,>=2.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2.9.1)\n",
+            "Requirement already satisfied: 
google-cloud-videointelligence<3,>=2.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (2.11.3)\n",
+            "Requirement already satisfied: google-cloud-vision<4,>=2 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (3.4.4)\n",
+            "Requirement already satisfied: 
google-cloud-recommendations-ai<0.11.0,>=0.1.0 in 
/usr/local/lib/python3.10/dist-packages (from apache-beam[gcp]) (0.10.4)\n",
+            "Requirement already satisfied: 
google-cloud-aiplatform<2.0,>=1.26.0 in /usr/local/lib/python3.10/dist-packages 
(from apache-beam[gcp]) (1.28.0)\n",
+            "Requirement already satisfied: oauth2client>=1.4.12 in 
/usr/local/lib/python3.10/dist-packages (from 
google-apitools<0.5.32,>=0.5.31->apache-beam[gcp]) (4.1.3)\n",
+            "Requirement already satisfied: six>=1.12.0 in 
/usr/local/lib/python3.10/dist-packages (from 
google-apitools<0.5.32,>=0.5.31->apache-beam[gcp]) (1.16.0)\n",
+            "Requirement already satisfied: pyasn1-modules>=0.2.1 in 
/usr/local/lib/python3.10/dist-packages (from 
google-auth<3,>=1.18.0->apache-beam[gcp]) (0.3.0)\n",
+            "Requirement already satisfied: rsa<5,>=3.1.4 in 
/usr/local/lib/python3.10/dist-packages (from 
google-auth<3,>=1.18.0->apache-beam[gcp]) (4.9)\n",
+            "Requirement already satisfied: 
google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0
 in /usr/local/lib/python3.10/dist-packages (from 
google-cloud-aiplatform<2.0,>=1.26.0->apache-beam[gcp]) (2.11.1)\n",
+            "Requirement already satisfied: packaging>=14.3 in 
/usr/local/lib/python3.10/dist-packages (from 
google-cloud-aiplatform<2.0,>=1.26.0->apache-beam[gcp]) (23.1)\n",
+            "Requirement already satisfied: 
google-cloud-storage<3.0.0dev,>=1.32.0 in 
/usr/local/lib/python3.10/dist-packages (from 
google-cloud-aiplatform<2.0,>=1.26.0->apache-beam[gcp]) (2.8.0)\n",
+            "Requirement already satisfied: 
google-cloud-resource-manager<3.0.0dev,>=1.3.3 in 
/usr/local/lib/python3.10/dist-packages (from 
google-cloud-aiplatform<2.0,>=1.26.0->apache-beam[gcp]) (1.10.2)\n",
+            "Requirement already satisfied: shapely<2.0.0 in 
/usr/local/lib/python3.10/dist-packages (from 
google-cloud-aiplatform<2.0,>=1.26.0->apache-beam[gcp]) (1.8.5.post1)\n",
+            "Requirement already satisfied: 
google-resumable-media<3.0dev,>=0.6.0 in 
/usr/local/lib/python3.10/dist-packages (from 
google-cloud-bigquery<4,>=2.0.0->apache-beam[gcp]) (2.5.0)\n",
+            "Requirement already satisfied: 
grpc-google-iam-v1<1.0.0dev,>=0.12.4 in /usr/local/lib/python3.10/dist-packages 
(from google-cloud-bigtable<3,>=2.19.0->apache-beam[gcp]) (0.12.6)\n",
+            "Requirement already satisfied: grpcio-status>=1.33.2 in 
/usr/local/lib/python3.10/dist-packages (from 
google-cloud-pubsub<3,>=2.1.0->apache-beam[gcp]) (1.48.2)\n",
+            "Requirement already satisfied: overrides<7.0.0,>=6.0.1 in 
/usr/local/lib/python3.10/dist-packages (from 
google-cloud-pubsublite<2,>=1.2.0->apache-beam[gcp]) (6.5.0)\n",
+            "Requirement already satisfied: sqlparse>=0.4.4 in 
/usr/local/lib/python3.10/dist-packages (from 
google-cloud-spanner<4,>=3.0.0->apache-beam[gcp]) (0.4.4)\n",
+            "Requirement already satisfied: docopt in 
/usr/local/lib/python3.10/dist-packages (from 
hdfs<3.0.0,>=2.1.0->apache-beam[gcp]) (0.6.2)\n",
+            "Requirement already satisfied: 
pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in 
/usr/local/lib/python3.10/dist-packages (from 
httplib2<0.23.0,>=0.8->apache-beam[gcp]) (3.1.0)\n",
+            "Requirement already satisfied: dnspython<3.0.0,>=1.16.0 in 
/usr/local/lib/python3.10/dist-packages (from 
pymongo<5.0.0,>=3.8.0->apache-beam[gcp]) (2.4.0)\n",
+            "Requirement already satisfied: urllib3<1.27,>=1.21.1 in 
/usr/local/lib/python3.10/dist-packages (from 
requests<3.0.0,>=2.24.0->apache-beam[gcp]) (1.26.16)\n",
+            "Requirement already satisfied: certifi>=2017.4.17 in 
/usr/local/lib/python3.10/dist-packages (from 
requests<3.0.0,>=2.24.0->apache-beam[gcp]) (2023.5.7)\n",
+            "Requirement already satisfied: charset-normalizer~=2.0.0 in 
/usr/local/lib/python3.10/dist-packages (from 
requests<3.0.0,>=2.24.0->apache-beam[gcp]) (2.0.12)\n",
+            "Requirement already satisfied: idna<4,>=2.5 in 
/usr/local/lib/python3.10/dist-packages (from 
requests<3.0.0,>=2.24.0->apache-beam[gcp]) (3.4)\n",
+            "Requirement already satisfied: httpcore>=0.17.3 in 
/usr/local/lib/python3.10/dist-packages (from 
dnspython<3.0.0,>=1.16.0->pymongo<5.0.0,>=3.8.0->apache-beam[gcp]) (0.17.3)\n",
+            "Requirement already satisfied: sniffio<2.0,>=1.1 in 
/usr/local/lib/python3.10/dist-packages (from 
dnspython<3.0.0,>=1.16.0->pymongo<5.0.0,>=3.8.0->apache-beam[gcp]) (1.3.0)\n",
+            "Requirement already satisfied: 
googleapis-common-protos<2.0.dev0,>=1.56.2 in 
/usr/local/lib/python3.10/dist-packages (from 
google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform<2.0,>=1.26.0->apache-beam[gcp])
 (1.59.1)\n",
+            "Requirement already satisfied: google-crc32c<2.0dev,>=1.0 in 
/usr/local/lib/python3.10/dist-packages (from 
google-resumable-media<3.0dev,>=0.6.0->google-cloud-bigquery<4,>=2.0.0->apache-beam[gcp])
 (1.5.0)\n",
+            "Requirement already satisfied: pyasn1>=0.1.7 in 
/usr/local/lib/python3.10/dist-packages (from 
oauth2client>=1.4.12->google-apitools<0.5.32,>=0.5.31->apache-beam[gcp]) 
(0.5.0)\n",
+            "Requirement already satisfied: h11<0.15,>=0.13 in 
/usr/local/lib/python3.10/dist-packages (from 
httpcore>=0.17.3->dnspython<3.0.0,>=1.16.0->pymongo<5.0.0,>=3.8.0->apache-beam[gcp])
 (0.14.0)\n",
+            "Requirement already satisfied: anyio<5.0,>=3.0 in 
/usr/local/lib/python3.10/dist-packages (from 
httpcore>=0.17.3->dnspython<3.0.0,>=1.16.0->pymongo<5.0.0,>=3.8.0->apache-beam[gcp])
 (3.7.1)\n",
+            "Requirement already satisfied: exceptiongroup in 
/usr/local/lib/python3.10/dist-packages (from 
anyio<5.0,>=3.0->httpcore>=0.17.3->dnspython<3.0.0,>=1.16.0->pymongo<5.0.0,>=3.8.0->apache-beam[gcp])
 (1.1.2)\n"
+          ]
+        }
+      ]
+    },
+    {
+      "cell_type": "markdown",
+      "source": [
+        "Note that below, **us-central1** is hardcoded as the location. This 
is because of the limited number of 
[locations](https://cloud.google.com/healthcare-api/docs/how-tos/nlp) the API 
currently supports."
+      ],
+      "metadata": {
+        "id": "D7lJqW2PRFcN"
+      }
+    },
+    {
+      "cell_type": "code",
+      "source": [
+        "#Change this variable to True if you want to debug the Interactive 
Runner Pipeline else it uses Dataflow\n",
+        "debug = False\n",
+        "DATASET=\"<YOUR_DATASET_NAME>\"\n",
+        "TEMP_LOCATION=\"<YOUR_TEMP_LOCATION>\"\n",
+        "PROJECT='<YOUR_PROJECT_ID>'\n",
+        "LOCATION='us-central1'\n",
+        
"URL=f'https://healthcare.googleapis.com/v1/projects/{PROJECT}/locations/{LOCATION}/services/nlp:analyzeEntities'\n",
+        
"NLP_SERVICE=f'projects/{PROJECT}/locations/{LOCATION}/services/nlp'\n",
+        "GCS_BUCKET=PROJECT"
+      ],
+      "metadata": {
+        "id": "s9lhe5CZ5F3o"
+      },
+      "execution_count": null,
+      "outputs": []
+    },
+    {
+      "cell_type": "markdown",
+      "source": [
+        "**BigQuery Setup**\n",
+        "\n",
+        "We will be using BigQuery to warehouse the structured data revealed 
in the output of the Healthcare NLP API. For this purpose, we create 3 tables 
to organize the data"
+      ],
+      "metadata": {
+        "id": "DI_Qkyn75LO-"
+      }
+    },
+    {
+      "cell_type": "code",
+      "source": [
+        "from google.cloud import bigquery\n",
+        "\n",
+        "# Construct a BigQuery client object.\n",
+        "\n",
+        "TABLE_ENTITY=\"entity\"\n",
+        "TABLE_REL=\"relations\"\n",
+        "TABLE_ENTITYMENTIONS=\"entitymentions\"\n",
+        "\n",
+        "schemaEntity = [\n",
+        "    bigquery.SchemaField(\"entityId\", \"STRING\", 
mode=\"NULLABLE\"),\n",
+        "    bigquery.SchemaField(\"preferredTerm\", \"STRING\", 
mode=\"NULLABLE\"),\n",
+        "    bigquery.SchemaField(\"vocabularyCodes\", \"STRING\", 
mode=\"REPEATED\"),\n",
+        "]\n",
+        "\n",
+        "schemaRelations = [\n",
+        "    bigquery.SchemaField(\"subjectId\", \"STRING\", 
mode=\"NULLABLE\"),\n",
+        "    bigquery.SchemaField(\"objectId\", \"STRING\", 
mode=\"NULLABLE\"),\n",
+        "    bigquery.SchemaField(\"confidence\", \"FLOAT64\", 
mode=\"NULLABLE\"),\n",
+        "    bigquery.SchemaField(\"id\", \"STRING\", mode=\"NULLABLE\"),\n",
+        "]\n",
+        "\n",
+        "schemaEntityMentions = [\n",
+        "    bigquery.SchemaField(\"mentionId\", \"STRING\", 
mode=\"NULLABLE\"),\n",
+        "    bigquery.SchemaField(\"type\", \"STRING\", mode=\"NULLABLE\"),\n",
+        "    bigquery.SchemaField(\n",
+        "        \"text\",\n",
+        "        \"RECORD\",\n",
+        "         mode=\"NULLABLE\",\n",
+        "         fields=[\n",
+        "             bigquery.SchemaField(\"content\", \"STRING\", 
mode=\"NULLABLE\"),\n",
+        "             bigquery.SchemaField(\"beginOffset\", \"INTEGER\", 
mode=\"NULLABLE\"),\n",
+        "         ],\n",
+        "    ),\n",
+        "    bigquery.SchemaField(\n",
+        "        \"linkedEntities\",\n",
+        "        \"RECORD\",\n",
+        "         mode=\"REPEATED\",\n",
+        "         fields=[\n",
+        "             bigquery.SchemaField(\"entityId\", \"STRING\", 
mode=\"NULLABLE\"),\n",
+        "         ],\n",
+        "    ),\n",
+        "    bigquery.SchemaField(\n",
+        "        \"temporalAssessment\",\n",
+        "        \"RECORD\",\n",
+        "         mode=\"NULLABLE\",\n",
+        "         fields=[\n",
+        "             bigquery.SchemaField(\"value\", \"STRING\", 
mode=\"NULLABLE\"),\n",
+        "             bigquery.SchemaField(\"confidence\", \"FLOAT64\", 
mode=\"NULLABLE\"),\n",
+        "         ],\n",
+        "    ),\n",
+        "    bigquery.SchemaField(\n",
+        "        \"certaintyAssessment\",\n",
+        "        \"RECORD\",\n",
+        "         mode=\"NULLABLE\",\n",
+        "         fields=[\n",
+        "             bigquery.SchemaField(\"value\", \"STRING\", 
mode=\"NULLABLE\"),\n",
+        "             bigquery.SchemaField(\"confidence\", \"FLOAT64\", 
mode=\"NULLABLE\"),\n",
+        "         ],\n",
+        "    ),\n",
+        "    bigquery.SchemaField(\n",
+        "        \"subject\",\n",
+        "        \"RECORD\",\n",
+        "         mode=\"NULLABLE\",\n",
+        "         fields=[\n",
+        "             bigquery.SchemaField(\"value\", \"STRING\", 
mode=\"NULLABLE\"),\n",
+        "             bigquery.SchemaField(\"confidence\", \"FLOAT64\", 
mode=\"NULLABLE\"),\n",
+        "         ],\n",
+        "    ),\n",
+        "    bigquery.SchemaField(\"confidence\", \"FLOAT64\", 
mode=\"NULLABLE\"),\n",
+        "    bigquery.SchemaField(\"id\", \"STRING\", mode=\"NULLABLE\")\n",
+        "]\n",
+        "\n",
+        "client = bigquery.Client()\n",
+        "\n",
+        "# Create Table IDs\n",
+        "table_ent = PROJECT+\".\"+DATASET+\".\"+TABLE_ENTITY\n",
+        "table_rel = PROJECT+\".\"+DATASET+\".\"+TABLE_REL\n",
+        "table_mentions = PROJECT+\".\"+DATASET+\".\"+TABLE_ENTITYMENTIONS\n",
+        "\n",
+        "# If table exists, delete the tables.\n",
+        "client.delete_table(table_ent, not_found_ok=True)\n",
+        "client.delete_table(table_rel, not_found_ok=True)\n",
+        "client.delete_table(table_mentions, not_found_ok=True)\n",
+        "\n",
+        "# Create tables\n",
+        "\n",
+        "table = bigquery.Table(table_ent, schema=schemaEntity)\n",
+        "table = client.create_table(table)  # Make an API request.\n",
+        "\n",
+        "print(\n",
+        "    \"Created table {}.{}.{}\".format(table.project, 
table.dataset_id, table.table_id)\n",
+        ")\n",
+        "\n",
+        "table = bigquery.Table(table_rel, schema=schemaRelations)\n",
+        "table = client.create_table(table)  # Make an API request.\n",
+        "print(\n",
+        "    \"Created table {}.{}.{}\".format(table.project, 
table.dataset_id, table.table_id)\n",
+        ")\n",
+        "table = bigquery.Table(table_mentions, 
schema=schemaEntityMentions)\n",
+        "table = client.create_table(table)  # Make an API request.\n",
+        "print(\n",
+        "    \"Created table {}.{}.{}\".format(table.project, 
table.dataset_id, table.table_id)\n",
+        ")"
+      ],
+      "metadata": {
+        "id": "bZDqtFVE5Wd_"
+      },
+      "execution_count": null,
+      "outputs": []
+    },
+    {
+      "cell_type": "markdown",
+      "source": [
+        "**Pipeline Setup**\n",
+        "\n",
+        "For the purpose of experimenting, I have setup an interactiveRunner. 
But this should be changed to a DatafowRunner once you are comfortable with it"

Review Comment:
   I agree, but I think if we want to standardize this we should write some 
documentation on notebooks guidelines. I can take this as a follow up AI.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to