Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit 79d6d57

Browse files
gguussbusunkim96
authored andcommitted
* Reorganizes samples, adds new snippet, and demonstrates switching API versions using GAPIC manual layer. * Corrects beta version in link * Copyright dates on new files * Removes README with nav, changes all snippets to use v1beta2 in beta folder * Fixes v1beta2 test on GCS sentiment.
1 parent 7a656a5 commit 79d6d57

File tree

16 files changed

+539
-0
lines changed

16 files changed

+539
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
.. This file is automatically generated. Do not edit this file directly.
2+
3+
Google Cloud Natural Language API Python Samples
4+
===============================================================================
5+
6+
This directory contains samples for Google Cloud Natural Language API. The `Google Cloud Natural Language API`_ provides natural language understanding technologies to developers, including sentiment analysis, entity recognition, and syntax analysis. This API is part of the larger Cloud Machine Learning API.
7+
8+
9+
10+
11+
.. _Google Cloud Natural Language API: https://cloud.google.com/natural-language/docs/
12+
13+
Setup
14+
-------------------------------------------------------------------------------
15+
16+
17+
Authentication
18+
++++++++++++++
19+
20+
Authentication is typically done through `Application Default Credentials`_,
21+
which means you do not have to change the code to authenticate as long as
22+
your environment has credentials. You have a few options for setting up
23+
authentication:
24+
25+
#. When running locally, use the `Google Cloud SDK`_
26+
27+
.. code-block:: bash
28+
29+
gcloud beta auth application-default login
30+
31+
32+
#. When running on App Engine or Compute Engine, credentials are already
33+
set-up. However, you may need to configure your Compute Engine instance
34+
with `additional scopes`_.
35+
36+
#. You can create a `Service Account key file`_. This file can be used to
37+
authenticate to Google Cloud Platform services from any environment. To use
38+
the file, set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to
39+
the path to the key file, for example:
40+
41+
.. code-block:: bash
42+
43+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json
44+
45+
.. _Application Default Credentials: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow
46+
.. _additional scopes: https://cloud.google.com/compute/docs/authentication#using
47+
.. _Service Account key file: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount
48+
49+
Install Dependencies
50+
++++++++++++++++++++
51+
52+
#. Install `pip`_ and `virtualenv`_ if you do not already have them.
53+
54+
#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.
55+
56+
.. code-block:: bash
57+
58+
$ virtualenv env
59+
$ source env/bin/activate
60+
61+
#. Install the dependencies needed to run the samples.
62+
63+
.. code-block:: bash
64+
65+
$ pip install -r requirements.txt
66+
67+
.. _pip: https://pip.pypa.io/
68+
.. _virtualenv: https://virtualenv.pypa.io/
69+
70+
Samples
71+
-------------------------------------------------------------------------------
72+
73+
Quickstart
74+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
75+
76+
77+
78+
To run this sample:
79+
80+
.. code-block:: bash
81+
82+
$ python quickstart.py
83+
84+
85+
Snippets
86+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
87+
88+
89+
90+
To run this sample:
91+
92+
.. code-block:: bash
93+
94+
$ python snippets.py
95+
96+
usage: snippets.py [-h]
97+
{sentiment-entities-text,sentiment-entities-file,sentiment-text,sentiment-file,entities-text,entities-file,syntax-text,syntax-file}
98+
...
99+
100+
This application demonstrates how to perform basic operations with the
101+
Google Cloud Natural Language API
102+
103+
For more information, the documentation at
104+
https://cloud.google.com/natural-language/docs.
105+
106+
positional arguments:
107+
{sentiment-entities-text,sentiment-entities-file,sentiment-text,sentiment-file,entities-text,entities-file,syntax-text,syntax-file}
108+
sentiment-entities-text
109+
Detects entity sentiment in the provided text.
110+
sentiment-entities-file
111+
Detects entity sentiment in a Google Cloud Storage
112+
file.
113+
sentiment-text Detects sentiment in the text.
114+
sentiment-file Detects sentiment in the file located in Google Cloud
115+
Storage.
116+
entities-text Detects entities in the text.
117+
entities-file Detects entities in the file located in Google Cloud
118+
Storage.
119+
syntax-text Detects syntax in the text.
120+
syntax-file Detects syntax in the file located in Google Cloud
121+
Storage.
122+
123+
optional arguments:
124+
-h, --help show this help message and exit
125+
126+
127+
128+
129+
The client library
130+
-------------------------------------------------------------------------------
131+
132+
This sample uses the `Google Cloud Client Library for Python`_.
133+
You can read the documentation for more details on API usage and use GitHub
134+
to `browse the source`_ and `report issues`_.
135+
136+
.. Google Cloud Client Library for Python:
137+
https://googlecloudplatform.github.io/google-cloud-python/
138+
.. browse the source:
139+
https://github.com/GoogleCloudPlatform/google-cloud-python
140+
.. report issues:
141+
https://github.com/GoogleCloudPlatform/google-cloud-python/issues
142+
143+
144+
.. _Google Cloud SDK: https://cloud.google.com/sdk/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file is used to generate README.rst
2+
3+
product:
4+
name: Google Cloud Natural Language API
5+
short_name: Cloud Natural Language API
6+
url: https://cloud.google.com/natural-language/docs/
7+
description: >
8+
The `Google Cloud Natural Language API`_ provides natural language
9+
understanding technologies to developers, including sentiment analysis,
10+
entity recognition, and syntax analysis. This API is part of the larger
11+
Cloud Machine Learning API.
12+
13+
setup:
14+
- auth
15+
- install_deps
16+
17+
samples:
18+
- name: Quickstart
19+
file: quickstart.py
20+
- name: Snippets
21+
file: snippets.py
22+
show_help: true
23+
24+
cloud_client_library: true

0 commit comments

Comments
 (0)