mik-laj commented on a change in pull request #4980: [AIRFLOW-3971] Add Google 
Cloud Natural Language operators
URL: https://github.com/apache/airflow/pull/4980#discussion_r270690394
 
 

 ##########
 File path: airflow/contrib/example_dags/example_gcp_natural_language.py
 ##########
 @@ -0,0 +1,116 @@
+# -*- coding: utf-8 -*-
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Example Airflow DAG for Google Natural Language service
+"""
+
+
+from google.cloud.language_v1.proto.language_service_pb2 import Document
+
+import airflow
+from airflow import models
+from airflow.contrib.operators.gcp_natural_language_operator import (
+    CloudLanguageAnalyzeEntitiesOperator,
+    CloudLanguageAnalyzeEntitySentimentOperator,
+    CloudLanguageAnalyzeSentimentOperator,
+    CloudLanguageClassifyTextOperator,
+)
+from airflow.operators.bash_operator import BashOperator
+
+# [START howto_operator_natural_language_document_text]
+TEXT = """
+Airflow is a platform to programmatically author, schedule and monitor 
workflows.
+
+Use Airflow to author workflows as Directed Acyclic Graphs (DAGs) of tasks. 
The Airflow scheduler executes
+ your tasks on an array of workers while following the specified dependencies. 
Rich command line utilities
+ make performing complex surgeries on DAGs a snap. The rich user interface 
makes it easy to visualize
+ pipelines running in production, monitor progress, and troubleshoot issues 
when needed.
+"""
+document = Document(content=TEXT, type="PLAIN_TEXT")
+# [END howto_operator_natural_language_document_text]
+
+# [START howto_operator_natural_language_document_gcs]
+GCS_CONTENT_URI = "gs://my-text-bucket/sentiment-me.txt"
+document_gcs = Document(gcs_content_uri=GCS_CONTENT_URI, type="PLAIN_TEXT")
+# [END howto_operator_natural_language_document_gcs]
+
+
+default_args = {"start_date": airflow.utils.dates.days_ago(1)}
+
+with models.DAG(
+    "example_gcp_natural_language",
+    default_args=default_args,
+    schedule_interval=None,  # Override to match your needs
+) as dag:
+
+    # [START howto_operator_natural_language_analyze_entities]
 
 Review comment:
   Conflict will never happen because the tags are always associated with the 
file. Prefixes are completely unnecessary. However, I will introduce your 
suggestion in a moment.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to