From 0a3b821eafd946c8a9c29fbbd6a623d7932355a4 Mon Sep 17 00:00:00 2001 From: Harikumar Devandla Date: Thu, 1 Oct 2020 14:31:17 -0700 Subject: [PATCH 1/4] Remove samples --- language/api/README.rst | 94 ------- language/api/README.rst.in | 22 -- language/api/analyze.py | 102 ------- language/api/analyze_test.py | 259 ------------------ language/api/requirements-test.txt | 1 - language/api/requirements.txt | 3 - language/automl/requirements-test.txt | 1 - language/automl/requirements.txt | 1 - language/automl/resources/test.txt | 1 - language/classify_text/README.rst | 126 --------- language/classify_text/README.rst.in | 28 -- .../classify_text/classify_text_tutorial.py | 252 ----------------- .../classify_text_tutorial_test.py | 91 ------ language/classify_text/requirements-test.txt | 1 - language/classify_text/requirements.txt | 2 - .../classify_text/resources/query_text1.txt | 1 - .../classify_text/resources/query_text2.txt | 1 - .../classify_text/resources/query_text3.txt | 1 - .../classify_text/resources/texts/android.txt | 1 - .../resources/texts/cat_in_the_hat.txt | 1 - .../resources/texts/cloud_computing.txt | 1 - .../classify_text/resources/texts/eclipse.txt | 1 - .../resources/texts/eclipse_of_the_sun.txt | 1 - .../classify_text/resources/texts/email.txt | 1 - .../classify_text/resources/texts/gcp.txt | 1 - .../classify_text/resources/texts/gmail.txt | 1 - .../classify_text/resources/texts/google.txt | 1 - .../resources/texts/harry_potter.txt | 1 - .../classify_text/resources/texts/matilda.txt | 1 - .../resources/texts/mobile_phone.txt | 1 - .../classify_text/resources/texts/mr_fox.txt | 1 - .../resources/texts/wireless.txt | 1 - language/cloud-client/.DS_Store | Bin 6148 -> 0 bytes language/cloud-client/v1/README.rst | 99 ------- language/cloud-client/v1/README.rst.in | 30 -- language/cloud-client/v1/quickstart.py | 47 ---- language/cloud-client/v1/quickstart_test.py | 22 -- .../cloud-client/v1/requirements-test.txt | 1 - language/cloud-client/v1/requirements.txt | 1 - language/cloud-client/v1/resources/text.txt | 1 - language/cloud-client/v1/set_endpoint.py | 40 --- language/cloud-client/v1/set_endpoint_test.py | 22 -- .../v1/language_sentiment_text.py | 58 ---- .../v1/language_sentiment_text_test.py | 28 -- .../v1/requirements-test.txt | 1 - .../generated-samples/v1/requirements.txt | 1 - language/sentiment/README.md | 53 ---- language/sentiment/requirements-test.txt | 1 - language/sentiment/requirements.txt | 1 - language/sentiment/resources/mixed.txt | 20 -- language/sentiment/resources/neg.txt | 4 - language/sentiment/resources/neutral.txt | 3 - language/sentiment/resources/pos.txt | 11 - language/sentiment/sentiment_analysis.py | 73 ----- language/sentiment/sentiment_analysis_test.py | 50 ---- 55 files changed, 1568 deletions(-) delete mode 100644 language/api/README.rst delete mode 100644 language/api/README.rst.in delete mode 100644 language/api/analyze.py delete mode 100644 language/api/analyze_test.py delete mode 100644 language/api/requirements-test.txt delete mode 100644 language/api/requirements.txt delete mode 100644 language/automl/requirements-test.txt delete mode 100644 language/automl/requirements.txt delete mode 100644 language/automl/resources/test.txt delete mode 100644 language/classify_text/README.rst delete mode 100644 language/classify_text/README.rst.in delete mode 100644 language/classify_text/classify_text_tutorial.py delete mode 100644 language/classify_text/classify_text_tutorial_test.py delete mode 100644 language/classify_text/requirements-test.txt delete mode 100644 language/classify_text/requirements.txt delete mode 100644 language/classify_text/resources/query_text1.txt delete mode 100644 language/classify_text/resources/query_text2.txt delete mode 100644 language/classify_text/resources/query_text3.txt delete mode 100644 language/classify_text/resources/texts/android.txt delete mode 100644 language/classify_text/resources/texts/cat_in_the_hat.txt delete mode 100644 language/classify_text/resources/texts/cloud_computing.txt delete mode 100644 language/classify_text/resources/texts/eclipse.txt delete mode 100644 language/classify_text/resources/texts/eclipse_of_the_sun.txt delete mode 100644 language/classify_text/resources/texts/email.txt delete mode 100644 language/classify_text/resources/texts/gcp.txt delete mode 100644 language/classify_text/resources/texts/gmail.txt delete mode 100644 language/classify_text/resources/texts/google.txt delete mode 100644 language/classify_text/resources/texts/harry_potter.txt delete mode 100644 language/classify_text/resources/texts/matilda.txt delete mode 100644 language/classify_text/resources/texts/mobile_phone.txt delete mode 100644 language/classify_text/resources/texts/mr_fox.txt delete mode 100644 language/classify_text/resources/texts/wireless.txt delete mode 100644 language/cloud-client/.DS_Store delete mode 100644 language/cloud-client/v1/README.rst delete mode 100644 language/cloud-client/v1/README.rst.in delete mode 100644 language/cloud-client/v1/quickstart.py delete mode 100644 language/cloud-client/v1/quickstart_test.py delete mode 100644 language/cloud-client/v1/requirements-test.txt delete mode 100644 language/cloud-client/v1/requirements.txt delete mode 100644 language/cloud-client/v1/resources/text.txt delete mode 100644 language/cloud-client/v1/set_endpoint.py delete mode 100644 language/cloud-client/v1/set_endpoint_test.py delete mode 100644 language/generated-samples/v1/language_sentiment_text.py delete mode 100644 language/generated-samples/v1/language_sentiment_text_test.py delete mode 100644 language/generated-samples/v1/requirements-test.txt delete mode 100644 language/generated-samples/v1/requirements.txt delete mode 100644 language/sentiment/README.md delete mode 100644 language/sentiment/requirements-test.txt delete mode 100644 language/sentiment/requirements.txt delete mode 100644 language/sentiment/resources/mixed.txt delete mode 100644 language/sentiment/resources/neg.txt delete mode 100644 language/sentiment/resources/neutral.txt delete mode 100644 language/sentiment/resources/pos.txt delete mode 100644 language/sentiment/sentiment_analysis.py delete mode 100644 language/sentiment/sentiment_analysis_test.py diff --git a/language/api/README.rst b/language/api/README.rst deleted file mode 100644 index 5f4edfd2773..00000000000 --- a/language/api/README.rst +++ /dev/null @@ -1,94 +0,0 @@ -.. This file is automatically generated. Do not edit this file directly. - -Google Cloud Natural Language API Python Samples -=============================================================================== - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=language/api/README.rst - - -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. - - - - -.. _Google Cloud Natural Language API: https://cloud.google.com/natural-language/docs/ - -Setup -------------------------------------------------------------------------------- - - -Authentication -++++++++++++++ - -This sample requires you to have authentication setup. Refer to the -`Authentication Getting Started Guide`_ for instructions on setting up -credentials for applications. - -.. _Authentication Getting Started Guide: - https://cloud.google.com/docs/authentication/getting-started - -Install Dependencies -++++++++++++++++++++ - -#. Clone python-docs-samples and change directory to the sample directory you want to use. - - .. code-block:: bash - - $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git - -#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. - - .. _Python Development Environment Setup Guide: - https://cloud.google.com/python/setup - -#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. - - .. code-block:: bash - - $ virtualenv env - $ source env/bin/activate - -#. Install the dependencies needed to run the samples. - - .. code-block:: bash - - $ pip install -r requirements.txt - -.. _pip: https://pip.pypa.io/ -.. _virtualenv: https://virtualenv.pypa.io/ - -Samples -------------------------------------------------------------------------------- - -Analyze syntax -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=language/api/analyze.py,language/api/README.rst - - - - -To run this sample: - -.. code-block:: bash - - $ python analyze.py - - usage: analyze.py [-h] {entities,sentiment,syntax} text - - Analyzes text using the Google Cloud Natural Language API. - - positional arguments: - {entities,sentiment,syntax} - text - - optional arguments: - -h, --help show this help message and exit - - - - - -.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/language/api/README.rst.in b/language/api/README.rst.in deleted file mode 100644 index f3195edf6b4..00000000000 --- a/language/api/README.rst.in +++ /dev/null @@ -1,22 +0,0 @@ -# This file is used to generate README.rst - -product: - name: Google Cloud Natural Language API - short_name: Cloud Natural Language API - url: https://cloud.google.com/natural-language/docs/ - description: > - 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. - -setup: -- auth -- install_deps - -samples: -- name: Analyze syntax - file: analyze.py - show_help: true - -folder: language/api \ No newline at end of file diff --git a/language/api/analyze.py b/language/api/analyze.py deleted file mode 100644 index a1e702b12cb..00000000000 --- a/language/api/analyze.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2016 Google, Inc -# -# Licensed 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. - -"""Analyzes text using the Google Cloud Natural Language API.""" - -import argparse -import json -import sys - -import googleapiclient.discovery - - -def get_native_encoding_type(): - """Returns the encoding type that matches Python's native strings.""" - if sys.maxunicode == 65535: - return 'UTF16' - else: - return 'UTF32' - - -def analyze_entities(text, encoding='UTF32'): - body = { - 'document': { - 'type': 'PLAIN_TEXT', - 'content': text, - }, - 'encoding_type': encoding, - } - - service = googleapiclient.discovery.build('language', 'v1') - - request = service.documents().analyzeEntities(body=body) - response = request.execute() - - return response - - -def analyze_sentiment(text, encoding='UTF32'): - body = { - 'document': { - 'type': 'PLAIN_TEXT', - 'content': text, - }, - 'encoding_type': encoding - } - - service = googleapiclient.discovery.build('language', 'v1') - - request = service.documents().analyzeSentiment(body=body) - response = request.execute() - - return response - - -def analyze_syntax(text, encoding='UTF32'): - body = { - 'document': { - 'type': 'PLAIN_TEXT', - 'content': text, - }, - 'encoding_type': encoding - } - - service = googleapiclient.discovery.build('language', 'v1') - - request = service.documents().analyzeSyntax(body=body) - response = request.execute() - - return response - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument('command', choices=[ - 'entities', 'sentiment', 'syntax']) - parser.add_argument('text') - - args = parser.parse_args() - - if args.command == 'entities': - result = analyze_entities(args.text, get_native_encoding_type()) - elif args.command == 'sentiment': - result = analyze_sentiment(args.text, get_native_encoding_type()) - elif args.command == 'syntax': - result = analyze_syntax(args.text, get_native_encoding_type()) - - print(json.dumps(result, indent=2)) diff --git a/language/api/analyze_test.py b/language/api/analyze_test.py deleted file mode 100644 index 08852c33ff7..00000000000 --- a/language/api/analyze_test.py +++ /dev/null @@ -1,259 +0,0 @@ -# Copyright 2016, Google, Inc. -# Licensed 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. - -import textwrap - -import analyze - - -def test_analyze_entities(): - result = analyze.analyze_entities( - 'Tom Sawyer is a book written by a guy known as Mark Twain.') - - assert result['language'] == 'en' - entities = result['entities'] - assert len(entities) - subject = entities[0] - assert subject['type'] == 'PERSON' - assert subject['name'].startswith('Tom') - - -def test_analyze_sentiment(capsys): - result = analyze.analyze_sentiment( - 'your face is really ugly and i hate it.') - - sentiment = result['documentSentiment'] - assert sentiment['score'] < 0 - assert sentiment['magnitude'] < 1 - - result = analyze.analyze_sentiment( - 'cheerio, mate - I greatly admire the pallor of your visage, and your ' - 'angle of repose leaves little room for improvement.') - - sentiment = result['documentSentiment'] - assert sentiment['score'] > 0 - assert sentiment['magnitude'] < 1 - - -def test_analyze_syntax(capsys): - result = analyze.analyze_syntax(textwrap.dedent(u'''\ - Keep away from people who try to belittle your ambitions. Small people - always do that, but the really great make you feel that you, too, can - become great. - - Mark Twain''')) - - assert len(result['tokens']) - first_token = result['tokens'][0] - assert first_token['text']['content'] == 'Keep' - assert first_token['partOfSpeech']['tag'] == 'VERB' - assert len(result['sentences']) > 1 - assert result['language'] == 'en' - - -def test_analyze_syntax_utf8(): - """Demonstrate the interpretation of the offsets when encoding=utf8. - - UTF8 is a variable-length encoding, where each character is at least 8 - bits. The offsets we get should be the index of the first byte of the - character. - """ - test_string = u'a \u00e3 \u0201 \U0001f636 b' - byte_array = test_string.encode('utf8') - result = analyze.analyze_syntax(test_string, encoding='UTF8') - tokens = result['tokens'] - - assert tokens[0]['text']['content'] == 'a' - offset = tokens[0]['text'].get('beginOffset', 0) - assert (byte_array[offset:offset+1].decode('utf8') == - tokens[0]['text']['content']) - - assert tokens[1]['text']['content'] == u'\u00e3' - offset = tokens[1]['text'].get('beginOffset', 0) - assert (byte_array[offset:offset+2].decode('utf8') == - tokens[1]['text']['content']) - - assert tokens[2]['text']['content'] == u'\u0201' - offset = tokens[2]['text'].get('beginOffset', 0) - assert (byte_array[offset:offset+2].decode('utf8') == - tokens[2]['text']['content']) - - assert tokens[3]['text']['content'] == u'\U0001f636' - offset = tokens[3]['text'].get('beginOffset', 0) - assert (byte_array[offset:offset+4].decode('utf8') == - tokens[3]['text']['content']) - - # This demonstrates that the offset takes into account the variable-length - # characters before the target token. - assert tokens[4]['text']['content'] == u'b' - offset = tokens[4]['text'].get('beginOffset', 0) - # 'b' is only one byte long - assert (byte_array[offset:offset+1].decode('utf8') == - tokens[4]['text']['content']) - - -def test_analyze_syntax_utf16(): - """Demonstrate the interpretation of the offsets when encoding=utf16. - - UTF16 is a variable-length encoding, where each character is at least 16 - bits. The returned offsets will be the index of the first 2-byte character - of the token. - """ - test_string = u'a \u00e3 \u0201 \U0001f636 b' - byte_array = test_string.encode('utf16') - # Remove the byte order marker, which the offsets don't account for - byte_array = byte_array[2:] - result = analyze.analyze_syntax(test_string, encoding='UTF16') - tokens = result['tokens'] - - assert tokens[0]['text']['content'] == 'a' - # The offset is an offset into an array where each entry is 16 bits. Since - # we have an 8-bit array, the offsets should be doubled to index into our - # array. - offset = 2 * tokens[0]['text'].get('beginOffset', 0) - assert (byte_array[offset:offset + 2].decode('utf16') == - tokens[0]['text']['content']) - - assert tokens[1]['text']['content'] == u'\u00e3' - offset = 2 * tokens[1]['text'].get('beginOffset', 0) - # A UTF16 character with a low codepoint is 16 bits (2 bytes) long, so - # slice out 2 bytes starting from the offset. Then interpret the bytes as - # utf16 for comparison. - assert (byte_array[offset:offset + 2].decode('utf16') == - tokens[1]['text']['content']) - - assert tokens[2]['text']['content'] == u'\u0201' - offset = 2 * tokens[2]['text'].get('beginOffset', 0) - # A UTF16 character with a low codepoint is 16 bits (2 bytes) long, so - # slice out 2 bytes starting from the offset. Then interpret the bytes as - # utf16 for comparison. - assert (byte_array[offset:offset + 2].decode('utf16') == - tokens[2]['text']['content']) - - assert tokens[3]['text']['content'] == u'\U0001f636' - offset = 2 * tokens[3]['text'].get('beginOffset', 0) - # A UTF16 character with a high codepoint is 32 bits (4 bytes) long, so - # slice out 4 bytes starting from the offset. Then interpret those bytes as - # utf16 for comparison. - assert (byte_array[offset:offset + 4].decode('utf16') == - tokens[3]['text']['content']) - - # This demonstrates that the offset takes into account the variable-length - # characters before the target token. - assert tokens[4]['text']['content'] == u'b' - offset = 2 * tokens[4]['text'].get('beginOffset', 0) - # Even though 'b' is only one byte long, utf16 still encodes it using 16 - # bits - assert (byte_array[offset:offset + 2].decode('utf16') == - tokens[4]['text']['content']) - - -def test_annotate_text_utf32(): - """Demonstrate the interpretation of the offsets when encoding=utf32. - - UTF32 is a fixed-length encoding, where each character is exactly 32 bits. - The returned offsets will be the index of the first 4-byte character - of the token. - - Python unicode objects index by the interpreted unicode character. This - means a given unicode character only ever takes up one slot in a unicode - string. This is equivalent to indexing into a UTF32 string, where all - characters are a fixed length and thus will only ever take up one slot. - - Thus, if you're indexing into a python unicode object, you can set - encoding to UTF32 to index directly into the unicode object (as opposed to - the byte arrays, as these examples do). - - Nonetheless, this test still demonstrates indexing into the byte array, for - consistency. Note that you could just index into the origin test_string - unicode object with the raw offset returned by the api (ie without - multiplying it by 4, as it is below). - """ - test_string = u'a \u00e3 \u0201 \U0001f636 b' - byte_array = test_string.encode('utf32') - # Remove the byte order marker, which the offsets don't account for - byte_array = byte_array[4:] - result = analyze.analyze_syntax(test_string, encoding='UTF32') - tokens = result['tokens'] - - assert tokens[0]['text']['content'] == 'a' - # The offset is an offset into an array where each entry is 32 bits. Since - # we have an 8-bit array, the offsets should be quadrupled to index into - # our array. - offset = 4 * tokens[0]['text'].get('beginOffset', 0) - assert (byte_array[offset:offset + 4].decode('utf32') == - tokens[0]['text']['content']) - - assert tokens[1]['text']['content'] == u'\u00e3' - offset = 4 * tokens[1]['text'].get('beginOffset', 0) - # A UTF32 character with a low codepoint is 32 bits (4 bytes) long, so - # slice out 4 bytes starting from the offset. Then interpret the bytes as - # utf32 for comparison. - assert (byte_array[offset:offset + 4].decode('utf32') == - tokens[1]['text']['content']) - - assert tokens[2]['text']['content'] == u'\u0201' - offset = 4 * tokens[2]['text'].get('beginOffset', 0) - # A UTF32 character with a low codepoint is 32 bits (4 bytes) long, so - # slice out 4 bytes starting from the offset. Then interpret the bytes as - # utf32 for comparison. - assert (byte_array[offset:offset + 4].decode('utf32') == - tokens[2]['text']['content']) - - assert tokens[3]['text']['content'] == u'\U0001f636' - offset = 4 * tokens[3]['text'].get('beginOffset', 0) - # A UTF32 character with a high codepoint is 32 bits (4 bytes) long, so - # slice out 4 bytes starting from the offset. Then interpret those bytes as - # utf32 for comparison. - assert (byte_array[offset:offset + 4].decode('utf32') == - tokens[3]['text']['content']) - - # This demonstrates that the offset takes into account the variable-length - # characters before the target token. - assert tokens[4]['text']['content'] == u'b' - offset = 4 * tokens[4]['text'].get('beginOffset', 0) - # Even though 'b' is only one byte long, utf32 still encodes it using 32 - # bits - assert (byte_array[offset:offset + 4].decode('utf32') == - tokens[4]['text']['content']) - - -def test_annotate_text_utf32_directly_index_into_unicode(): - """Demonstrate using offsets directly, using encoding=utf32. - - See the explanation for test_annotate_text_utf32. Essentially, indexing - into a utf32 array is equivalent to indexing into a python unicode object. - """ - test_string = u'a \u00e3 \u0201 \U0001f636 b' - result = analyze.analyze_syntax(test_string, encoding='UTF32') - tokens = result['tokens'] - - assert tokens[0]['text']['content'] == 'a' - offset = tokens[0]['text'].get('beginOffset', 0) - assert test_string[offset] == tokens[0]['text']['content'] - - assert tokens[1]['text']['content'] == u'\u00e3' - offset = tokens[1]['text'].get('beginOffset', 0) - assert test_string[offset] == tokens[1]['text']['content'] - - assert tokens[2]['text']['content'] == u'\u0201' - offset = tokens[2]['text'].get('beginOffset', 0) - assert test_string[offset] == tokens[2]['text']['content'] - - # Temporarily disabled - # assert tokens[3]['text']['content'] == u'\U0001f636' - # offset = tokens[3]['text'].get('beginOffset', 0) - # assert test_string[offset] == tokens[3]['text']['content'] - - # assert tokens[4]['text']['content'] == u'b' - # offset = tokens[4]['text'].get('beginOffset', 0) - # assert test_string[offset] == tokens[4]['text']['content'] diff --git a/language/api/requirements-test.txt b/language/api/requirements-test.txt deleted file mode 100644 index 7e460c8c866..00000000000 --- a/language/api/requirements-test.txt +++ /dev/null @@ -1 +0,0 @@ -pytest==6.0.1 diff --git a/language/api/requirements.txt b/language/api/requirements.txt deleted file mode 100644 index 41f4cf40e0d..00000000000 --- a/language/api/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -google-api-python-client==1.10.0 -google-auth==1.20.1 -google-auth-httplib2==0.0.4 diff --git a/language/automl/requirements-test.txt b/language/automl/requirements-test.txt deleted file mode 100644 index 7e460c8c866..00000000000 --- a/language/automl/requirements-test.txt +++ /dev/null @@ -1 +0,0 @@ -pytest==6.0.1 diff --git a/language/automl/requirements.txt b/language/automl/requirements.txt deleted file mode 100644 index 867dfc61e77..00000000000 --- a/language/automl/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -google-cloud-automl==1.0.1 diff --git a/language/automl/resources/test.txt b/language/automl/resources/test.txt deleted file mode 100644 index f0dde24bd9b..00000000000 --- a/language/automl/resources/test.txt +++ /dev/null @@ -1 +0,0 @@ -A strong taste of hazlenut and orange diff --git a/language/classify_text/README.rst b/language/classify_text/README.rst deleted file mode 100644 index a1112f21d01..00000000000 --- a/language/classify_text/README.rst +++ /dev/null @@ -1,126 +0,0 @@ -.. This file is automatically generated. Do not edit this file directly. - -Google Cloud Natural Language API Python Samples -=============================================================================== - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=language/classify_text/README.rst - - -This directory contains samples for Google Cloud Natural Language API. The `Google Cloud Natural Language API`_ provides natural language understanding technologies to developers. - -This tutorial demostrates how to use the `classify_text` method to classify content category of text files, and use the result to compare texts by their similarity to each other. See the `tutorial page`_ for details about this sample. - -.. _tutorial page: https://cloud.google.com/natural-language/docs/classify-text-tutorial - - - - -.. _Google Cloud Natural Language API: https://cloud.google.com/natural-language/docs/ - -Setup -------------------------------------------------------------------------------- - - -Authentication -++++++++++++++ - -This sample requires you to have authentication setup. Refer to the -`Authentication Getting Started Guide`_ for instructions on setting up -credentials for applications. - -.. _Authentication Getting Started Guide: - https://cloud.google.com/docs/authentication/getting-started - -Install Dependencies -++++++++++++++++++++ - -#. Clone python-docs-samples and change directory to the sample directory you want to use. - - .. code-block:: bash - - $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git - -#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. - - .. _Python Development Environment Setup Guide: - https://cloud.google.com/python/setup - -#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. - - .. code-block:: bash - - $ virtualenv env - $ source env/bin/activate - -#. Install the dependencies needed to run the samples. - - .. code-block:: bash - - $ pip install -r requirements.txt - -.. _pip: https://pip.pypa.io/ -.. _virtualenv: https://virtualenv.pypa.io/ - -Samples -------------------------------------------------------------------------------- - -Classify Text Tutorial -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=language/classify_text/classify_text_tutorial.py,language/classify_text/README.rst - - - - -To run this sample: - -.. code-block:: bash - - $ python classify_text_tutorial.py - - usage: classify_text_tutorial.py [-h] - {classify,index,query,query-category} ... - - Using the classify_text method to find content categories of text files, - Then use the content category labels to compare text similarity. - - For more information, see the tutorial page at - https://cloud.google.com/natural-language/docs/classify-text-tutorial. - - positional arguments: - {classify,index,query,query-category} - classify Classify the input text into categories. - index Classify each text file in a directory and write the - results to the index_file. - query Find the indexed files that are the most similar to - the query text. - query-category Find the indexed files that are the most similar to - the query label. The list of all available labels: - https://cloud.google.com/natural- - language/docs/categories - - optional arguments: - -h, --help show this help message and exit - - - - - -The client library -------------------------------------------------------------------------------- - -This sample uses the `Google Cloud Client Library for Python`_. -You can read the documentation for more details on API usage and use GitHub -to `browse the source`_ and `report issues`_. - -.. _Google Cloud Client Library for Python: - https://googlecloudplatform.github.io/google-cloud-python/ -.. _browse the source: - https://github.com/GoogleCloudPlatform/google-cloud-python -.. _report issues: - https://github.com/GoogleCloudPlatform/google-cloud-python/issues - - -.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/language/classify_text/README.rst.in b/language/classify_text/README.rst.in deleted file mode 100644 index 14ee6dc9aa4..00000000000 --- a/language/classify_text/README.rst.in +++ /dev/null @@ -1,28 +0,0 @@ -# This file is used to generate README.rst - -product: - name: Google Cloud Natural Language API - short_name: Cloud Natural Language API - url: https://cloud.google.com/natural-language/docs/ - description: > - The `Google Cloud Natural Language API`_ provides natural language - understanding technologies to developers. - - - This tutorial demostrates how to use the `classify_text` method to classify content category of text files, and use the result to compare texts by their similarity to each other. See the `tutorial page`_ for details about this sample. - - - .. _tutorial page: https://cloud.google.com/natural-language/docs/classify-text-tutorial - -setup: -- auth -- install_deps - -samples: -- name: Classify Text Tutorial - file: classify_text_tutorial.py - show_help: true - -cloud_client_library: true - -folder: language/classify_text \ No newline at end of file diff --git a/language/classify_text/classify_text_tutorial.py b/language/classify_text/classify_text_tutorial.py deleted file mode 100644 index d193e62e367..00000000000 --- a/language/classify_text/classify_text_tutorial.py +++ /dev/null @@ -1,252 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2017, Google, Inc. -# Licensed 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. - -"""Using the classify_text method to find content categories of text files, -Then use the content category labels to compare text similarity. - -For more information, see the tutorial page at -https://cloud.google.com/natural-language/docs/classify-text-tutorial. -""" - -# [START language_classify_text_tutorial_imports] -import argparse -import io -import json -import os - -from google.cloud import language -import numpy -import six -# [END language_classify_text_tutorial_imports] - - -# [START language_classify_text_tutorial_classify] -def classify(text, verbose=True): - """Classify the input text into categories. """ - - language_client = language.LanguageServiceClient() - - document = language.types.Document( - content=text, - type=language.enums.Document.Type.PLAIN_TEXT) - response = language_client.classify_text(document) - categories = response.categories - - result = {} - - for category in categories: - # Turn the categories into a dictionary of the form: - # {category.name: category.confidence}, so that they can - # be treated as a sparse vector. - result[category.name] = category.confidence - - if verbose: - print(text) - for category in categories: - print(u'=' * 20) - print(u'{:<16}: {}'.format('category', category.name)) - print(u'{:<16}: {}'.format('confidence', category.confidence)) - - return result -# [END language_classify_text_tutorial_classify] - - -# [START language_classify_text_tutorial_index] -def index(path, index_file): - """Classify each text file in a directory and write - the results to the index_file. - """ - - result = {} - for filename in os.listdir(path): - file_path = os.path.join(path, filename) - - if not os.path.isfile(file_path): - continue - - try: - with io.open(file_path, 'r') as f: - text = f.read() - categories = classify(text, verbose=False) - - result[filename] = categories - except Exception: - print('Failed to process {}'.format(file_path)) - - with io.open(index_file, 'w', encoding='utf-8') as f: - f.write(json.dumps(result, ensure_ascii=False)) - - print('Texts indexed in file: {}'.format(index_file)) - return result -# [END language_classify_text_tutorial_index] - - -def split_labels(categories): - """The category labels are of the form "/a/b/c" up to three levels, - for example "/Computers & Electronics/Software", and these labels - are used as keys in the categories dictionary, whose values are - confidence scores. - - The split_labels function splits the keys into individual levels - while duplicating the confidence score, which allows a natural - boost in how we calculate similarity when more levels are in common. - - Example: - If we have - - x = {"/a/b/c": 0.5} - y = {"/a/b": 0.5} - z = {"/a": 0.5} - - Then x and y are considered more similar than y and z. - """ - _categories = {} - for name, confidence in six.iteritems(categories): - labels = [label for label in name.split('/') if label] - for label in labels: - _categories[label] = confidence - - return _categories - - -def similarity(categories1, categories2): - """Cosine similarity of the categories treated as sparse vectors.""" - categories1 = split_labels(categories1) - categories2 = split_labels(categories2) - - norm1 = numpy.linalg.norm(list(categories1.values())) - norm2 = numpy.linalg.norm(list(categories2.values())) - - # Return the smallest possible similarity if either categories is empty. - if norm1 == 0 or norm2 == 0: - return 0.0 - - # Compute the cosine similarity. - dot = 0.0 - for label, confidence in six.iteritems(categories1): - dot += confidence * categories2.get(label, 0.0) - - return dot / (norm1 * norm2) - - -# [START language_classify_text_tutorial_query] -def query(index_file, text, n_top=3): - """Find the indexed files that are the most similar to - the query text. - """ - - with io.open(index_file, 'r') as f: - index = json.load(f) - - # Get the categories of the query text. - query_categories = classify(text, verbose=False) - - similarities = [] - for filename, categories in six.iteritems(index): - similarities.append( - (filename, similarity(query_categories, categories))) - - similarities = sorted(similarities, key=lambda p: p[1], reverse=True) - - print('=' * 20) - print('Query: {}\n'.format(text)) - for category, confidence in six.iteritems(query_categories): - print('\tCategory: {}, confidence: {}'.format(category, confidence)) - print('\nMost similar {} indexed texts:'.format(n_top)) - for filename, sim in similarities[:n_top]: - print('\tFilename: {}'.format(filename)) - print('\tSimilarity: {}'.format(sim)) - print('\n') - - return similarities -# [END language_classify_text_tutorial_query] - - -# [START language_classify_text_tutorial_query_category] -def query_category(index_file, category_string, n_top=3): - """Find the indexed files that are the most similar to - the query label. - - The list of all available labels: - https://cloud.google.com/natural-language/docs/categories - """ - - with io.open(index_file, 'r') as f: - index = json.load(f) - - # Make the category_string into a dictionary so that it is - # of the same format as what we get by calling classify. - query_categories = {category_string: 1.0} - - similarities = [] - for filename, categories in six.iteritems(index): - similarities.append( - (filename, similarity(query_categories, categories))) - - similarities = sorted(similarities, key=lambda p: p[1], reverse=True) - - print('=' * 20) - print('Query: {}\n'.format(category_string)) - print('\nMost similar {} indexed texts:'.format(n_top)) - for filename, sim in similarities[:n_top]: - print('\tFilename: {}'.format(filename)) - print('\tSimilarity: {}'.format(sim)) - print('\n') - - return similarities -# [END language_classify_text_tutorial_query_category] - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=argparse.RawDescriptionHelpFormatter) - subparsers = parser.add_subparsers(dest='command') - classify_parser = subparsers.add_parser( - 'classify', help=classify.__doc__) - classify_parser.add_argument( - 'text', help='The text to be classified. ' - 'The text needs to have at least 20 tokens.') - index_parser = subparsers.add_parser( - 'index', help=index.__doc__) - index_parser.add_argument( - 'path', help='The directory that contains ' - 'text files to be indexed.') - index_parser.add_argument( - '--index_file', help='Filename for the output JSON.', - default='index.json') - query_parser = subparsers.add_parser( - 'query', help=query.__doc__) - query_parser.add_argument( - 'index_file', help='Path to the index JSON file.') - query_parser.add_argument( - 'text', help='Query text.') - query_category_parser = subparsers.add_parser( - 'query-category', help=query_category.__doc__) - query_category_parser.add_argument( - 'index_file', help='Path to the index JSON file.') - query_category_parser.add_argument( - 'category', help='Query category.') - - args = parser.parse_args() - - if args.command == 'classify': - classify(args.text) - if args.command == 'index': - index(args.path, args.index_file) - if args.command == 'query': - query(args.index_file, args.text) - if args.command == 'query-category': - query_category(args.index_file, args.category) diff --git a/language/classify_text/classify_text_tutorial_test.py b/language/classify_text/classify_text_tutorial_test.py deleted file mode 100644 index 28de0562bdb..00000000000 --- a/language/classify_text/classify_text_tutorial_test.py +++ /dev/null @@ -1,91 +0,0 @@ -# Copyright 2016, Google, Inc. -# Licensed 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. - -import os - -import pytest - -import classify_text_tutorial - - -OUTPUT = 'index.json' -RESOURCES = os.path.join(os.path.dirname(__file__), 'resources') -QUERY_TEXT = """Google Home enables users to speak voice commands to interact -with services through the Home\'s intelligent personal assistant called -Google Assistant. A large number of services, both in-house and third-party, -are integrated, allowing users to listen to music, look at videos or photos, -or receive news updates entirely by voice.""" -QUERY_CATEGORY = '/Computers & Electronics/Software' - - -@pytest.fixture(scope='session') -def index_file(tmpdir_factory): - temp_file = tmpdir_factory.mktemp('tmp').join(OUTPUT) - temp_out = temp_file.strpath - classify_text_tutorial.index(os.path.join(RESOURCES, 'texts'), temp_out) - return temp_file - - -def test_classify(capsys): - with open(os.path.join(RESOURCES, 'query_text1.txt'), 'r') as f: - text = f.read() - classify_text_tutorial.classify(text) - out, err = capsys.readouterr() - assert 'category' in out - - -def test_index(capsys, tmpdir): - temp_dir = tmpdir.mkdir('tmp') - temp_out = temp_dir.join(OUTPUT).strpath - - classify_text_tutorial.index(os.path.join(RESOURCES, 'texts'), temp_out) - out, err = capsys.readouterr() - - assert OUTPUT in out - assert len(temp_dir.listdir()) == 1 - - -def test_query_text(capsys, index_file): - temp_out = index_file.strpath - - classify_text_tutorial.query(temp_out, QUERY_TEXT) - out, err = capsys.readouterr() - - assert 'Filename: cloud_computing.txt' in out - - -def test_query_category(capsys, index_file): - temp_out = index_file.strpath - - classify_text_tutorial.query_category(temp_out, QUERY_CATEGORY) - out, err = capsys.readouterr() - - assert 'Filename: cloud_computing.txt' in out - - -def test_split_labels(): - categories = {'/a/b/c': 1.0} - split_categories = {'a': 1.0, 'b': 1.0, 'c': 1.0} - assert classify_text_tutorial.split_labels(categories) == split_categories - - -def test_similarity(): - empty_categories = {} - categories1 = {'/a/b/c': 1.0, '/d/e': 1.0} - categories2 = {'/a/b': 1.0} - - assert classify_text_tutorial.similarity( - empty_categories, categories1) == 0.0 - assert classify_text_tutorial.similarity(categories1, categories1) > 0.99 - assert classify_text_tutorial.similarity(categories1, categories2) > 0 - assert classify_text_tutorial.similarity(categories1, categories2) < 1 diff --git a/language/classify_text/requirements-test.txt b/language/classify_text/requirements-test.txt deleted file mode 100644 index 7e460c8c866..00000000000 --- a/language/classify_text/requirements-test.txt +++ /dev/null @@ -1 +0,0 @@ -pytest==6.0.1 diff --git a/language/classify_text/requirements.txt b/language/classify_text/requirements.txt deleted file mode 100644 index 7ff166cc7e2..00000000000 --- a/language/classify_text/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -google-cloud-language==1.3.0 -numpy==1.19.1 diff --git a/language/classify_text/resources/query_text1.txt b/language/classify_text/resources/query_text1.txt deleted file mode 100644 index 304727304d1..00000000000 --- a/language/classify_text/resources/query_text1.txt +++ /dev/null @@ -1 +0,0 @@ -Google Home enables users to speak voice commands to interact with services through the Home's intelligent personal assistant called Google Assistant. A large number of services, both in-house and third-party, are integrated, allowing users to listen to music, look at videos or photos, or receive news updates entirely by voice. diff --git a/language/classify_text/resources/query_text2.txt b/language/classify_text/resources/query_text2.txt deleted file mode 100644 index eef573c6007..00000000000 --- a/language/classify_text/resources/query_text2.txt +++ /dev/null @@ -1 +0,0 @@ -The Hitchhiker's Guide to the Galaxy is the first of five books in the Hitchhiker's Guide to the Galaxy comedy science fiction "trilogy" by Douglas Adams (with the sixth written by Eoin Colfer). \ No newline at end of file diff --git a/language/classify_text/resources/query_text3.txt b/language/classify_text/resources/query_text3.txt deleted file mode 100644 index 1337d3c6477..00000000000 --- a/language/classify_text/resources/query_text3.txt +++ /dev/null @@ -1 +0,0 @@ -Goodnight Moon is an American children's picture book written by Margaret Wise Brown and illustrated by Clement Hurd. It was published on September 3, 1947, and is a highly acclaimed example of a bedtime story. \ No newline at end of file diff --git a/language/classify_text/resources/texts/android.txt b/language/classify_text/resources/texts/android.txt deleted file mode 100644 index 29dc1449c55..00000000000 --- a/language/classify_text/resources/texts/android.txt +++ /dev/null @@ -1 +0,0 @@ -Android is a mobile operating system developed by Google, based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablets. diff --git a/language/classify_text/resources/texts/cat_in_the_hat.txt b/language/classify_text/resources/texts/cat_in_the_hat.txt deleted file mode 100644 index bb5a853c694..00000000000 --- a/language/classify_text/resources/texts/cat_in_the_hat.txt +++ /dev/null @@ -1 +0,0 @@ -The Cat in the Hat is a children's book written and illustrated by Theodor Geisel under the pen name Dr. Seuss and first published in 1957. The story centers on a tall anthropomorphic cat, who wears a red and white-striped hat and a red bow tie. \ No newline at end of file diff --git a/language/classify_text/resources/texts/cloud_computing.txt b/language/classify_text/resources/texts/cloud_computing.txt deleted file mode 100644 index 88172adf1f4..00000000000 --- a/language/classify_text/resources/texts/cloud_computing.txt +++ /dev/null @@ -1 +0,0 @@ -Cloud computing is a computing-infrastructure and software model for enabling ubiquitous access to shared pools of configurable resources (such as computer networks, servers, storage, applications and services), which can be rapidly provisioned with minimal management effort, often over the Internet. \ No newline at end of file diff --git a/language/classify_text/resources/texts/eclipse.txt b/language/classify_text/resources/texts/eclipse.txt deleted file mode 100644 index 5d16217e520..00000000000 --- a/language/classify_text/resources/texts/eclipse.txt +++ /dev/null @@ -1 +0,0 @@ -A solar eclipse (as seen from the planet Earth) is a type of eclipse that occurs when the Moon passes between the Sun and Earth, and when the Moon fully or partially blocks (occults) the Sun. diff --git a/language/classify_text/resources/texts/eclipse_of_the_sun.txt b/language/classify_text/resources/texts/eclipse_of_the_sun.txt deleted file mode 100644 index 7236fc9d806..00000000000 --- a/language/classify_text/resources/texts/eclipse_of_the_sun.txt +++ /dev/null @@ -1 +0,0 @@ -Eclipse of the Sun is the debut novel by English author Phil Whitaker. It won the 1997 John Llewellyn Rhys Prize a Betty Trask Award in 1998, and was shortlisted for the 1997 Whitbread First Novel Award. diff --git a/language/classify_text/resources/texts/email.txt b/language/classify_text/resources/texts/email.txt deleted file mode 100644 index 3d430527b75..00000000000 --- a/language/classify_text/resources/texts/email.txt +++ /dev/null @@ -1 +0,0 @@ -Electronic mail (email or e-mail) is a method of exchanging messages between people using electronics. Email first entered substantial use in the 1960s and by the mid-1970s had taken the form now recognized as email. \ No newline at end of file diff --git a/language/classify_text/resources/texts/gcp.txt b/language/classify_text/resources/texts/gcp.txt deleted file mode 100644 index 1ed09b2c758..00000000000 --- a/language/classify_text/resources/texts/gcp.txt +++ /dev/null @@ -1 +0,0 @@ -Google Cloud Platform, offered by Google, is a suite of cloud computing services that runs on the same infrastructure that Google uses internally for its end-user products, such as Google Search and YouTube. Alongside a set of management tools, it provides a series of modular cloud services including computing, data storage, data analytics and machine learning. diff --git a/language/classify_text/resources/texts/gmail.txt b/language/classify_text/resources/texts/gmail.txt deleted file mode 100644 index 89c9704b117..00000000000 --- a/language/classify_text/resources/texts/gmail.txt +++ /dev/null @@ -1 +0,0 @@ -Gmail is a free, advertising-supported email service developed by Google. Users can access Gmail on the web and through mobile apps for Android and iOS, as well as through third-party programs that synchronize email content through POP or IMAP protocols. \ No newline at end of file diff --git a/language/classify_text/resources/texts/google.txt b/language/classify_text/resources/texts/google.txt deleted file mode 100644 index 06828635931..00000000000 --- a/language/classify_text/resources/texts/google.txt +++ /dev/null @@ -1 +0,0 @@ -Google is an American multinational technology company that specializes in Internet-related services and products. These include online advertising technologies, search, cloud computing, software, and hardware. diff --git a/language/classify_text/resources/texts/harry_potter.txt b/language/classify_text/resources/texts/harry_potter.txt deleted file mode 100644 index 339c10af05a..00000000000 --- a/language/classify_text/resources/texts/harry_potter.txt +++ /dev/null @@ -1 +0,0 @@ -Harry Potter is a series of fantasy novels written by British author J. K. Rowling. The novels chronicle the life of a young wizard, Harry Potter, and his friends Hermione Granger and Ron Weasley, all of whom are students at Hogwarts School of Witchcraft and Wizardry. \ No newline at end of file diff --git a/language/classify_text/resources/texts/matilda.txt b/language/classify_text/resources/texts/matilda.txt deleted file mode 100644 index e1539d7ee88..00000000000 --- a/language/classify_text/resources/texts/matilda.txt +++ /dev/null @@ -1 +0,0 @@ -Matilda is a book by British writer Roald Dahl. Matilda won the Children's Book Award in 1999. It was published in 1988 by Jonathan Cape in London, with 232 pages and illustrations by Quentin Blake. \ No newline at end of file diff --git a/language/classify_text/resources/texts/mobile_phone.txt b/language/classify_text/resources/texts/mobile_phone.txt deleted file mode 100644 index 725e22ef3a9..00000000000 --- a/language/classify_text/resources/texts/mobile_phone.txt +++ /dev/null @@ -1 +0,0 @@ -A mobile phone is a portable device that can make and receive calls over a radio frequency link while the user is moving within a telephone service area. The radio frequency link establishes a connection to the switching systems of a mobile phone operator, which provides access to the public switched telephone network (PSTN). \ No newline at end of file diff --git a/language/classify_text/resources/texts/mr_fox.txt b/language/classify_text/resources/texts/mr_fox.txt deleted file mode 100644 index 354feced2af..00000000000 --- a/language/classify_text/resources/texts/mr_fox.txt +++ /dev/null @@ -1 +0,0 @@ -Fantastic Mr Fox is a children's novel written by British author Roald Dahl. It was published in 1970, by George Allen & Unwin in the UK and Alfred A. Knopf in the U.S., with illustrations by Donald Chaffin. \ No newline at end of file diff --git a/language/classify_text/resources/texts/wireless.txt b/language/classify_text/resources/texts/wireless.txt deleted file mode 100644 index d742331c464..00000000000 --- a/language/classify_text/resources/texts/wireless.txt +++ /dev/null @@ -1 +0,0 @@ -Wireless communication, or sometimes simply wireless, is the transfer of information or power between two or more points that are not connected by an electrical conductor. The most common wireless technologies use radio waves. \ No newline at end of file diff --git a/language/cloud-client/.DS_Store b/language/cloud-client/.DS_Store deleted file mode 100644 index f344c851a0ee4f90f50741edcbb6236ebbbc354d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!A`{pJ@TK5l+$r=92a0ahvsOrXzLD-AJ zJA9_tJXH)nbRY%~4!+FJvKg5HW`G%3RR+wdX>F`(fm|0ezzqDF0XiQfDxqUA)u@gR z98?Q{m_xS`w5gY%9BI%om}q`|5!qLbhGr$adW`KG>lp@{#r$6`qDu@SWfEid#21KsjsJmF3xm%a2q`Ow4wopkZ oF4Z_sK|@`|7)w|2E~*mrOEM50gQ-UJpzx1?qJaly;7=L&02eA$o&W#< diff --git a/language/cloud-client/v1/README.rst b/language/cloud-client/v1/README.rst deleted file mode 100644 index e0d719464c5..00000000000 --- a/language/cloud-client/v1/README.rst +++ /dev/null @@ -1,99 +0,0 @@ -.. This file is automatically generated. Do not edit this file directly. - -Google Cloud Natural Language API Python Samples -=============================================================================== - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=language/cloud-client/v1/README.rst - - -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. - -- See the `migration guide`_ for information about migrating to Python client library v0.26.1. - -.. _migration guide: https://cloud.google.com/natural-language/docs/python-client-migration - - - - -.. _Google Cloud Natural Language API: https://cloud.google.com/natural-language/docs/ - -Setup -------------------------------------------------------------------------------- - - -Authentication -++++++++++++++ - -This sample requires you to have authentication setup. Refer to the -`Authentication Getting Started Guide`_ for instructions on setting up -credentials for applications. - -.. _Authentication Getting Started Guide: - https://cloud.google.com/docs/authentication/getting-started - -Install Dependencies -++++++++++++++++++++ - -#. Clone python-docs-samples and change directory to the sample directory you want to use. - - .. code-block:: bash - - $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git - -#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. - - .. _Python Development Environment Setup Guide: - https://cloud.google.com/python/setup - -#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. - - .. code-block:: bash - - $ virtualenv env - $ source env/bin/activate - -#. Install the dependencies needed to run the sample. - - .. code-block:: bash - - $ pip install -r requirements.txt - -.. _pip: https://pip.pypa.io/ -.. _virtualenv: https://virtualenv.pypa.io/ - -Sample -------------------------------------------------------------------------------- - -Quickstart -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=language/cloud-client/v1/quickstart.py,language/cloud-client/v1/README.rst - - - - -To run this sample: - -.. code-block:: bash - - $ python quickstart.py - - -The client library -------------------------------------------------------------------------------- - -This sample uses the `Google Cloud Client Library for Python`_. -You can read the documentation for more details on API usage and use GitHub -to `browse the source`_ and `report issues`_. - -.. _Google Cloud Client Library for Python: - https://googlecloudplatform.github.io/google-cloud-python/ -.. _browse the source: - https://github.com/GoogleCloudPlatform/google-cloud-python -.. _report issues: - https://github.com/GoogleCloudPlatform/google-cloud-python/issues - - -.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/language/cloud-client/v1/README.rst.in b/language/cloud-client/v1/README.rst.in deleted file mode 100644 index 9bf38dbf910..00000000000 --- a/language/cloud-client/v1/README.rst.in +++ /dev/null @@ -1,30 +0,0 @@ -# This file is used to generate README.rst - -product: - name: Google Cloud Natural Language API - short_name: Cloud Natural Language API - url: https://cloud.google.com/natural-language/docs/ - description: > - 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. - - - - See the `migration guide`_ for information about migrating to Python client library v0.26.1. - - - .. _migration guide: https://cloud.google.com/natural-language/docs/python-client-migration - -setup: -- auth -- install_deps - -samples: -- name: Quickstart - file: quickstart.py - show_help: true - -cloud_client_library: true - -folder: language/cloud-client/v1 \ No newline at end of file diff --git a/language/cloud-client/v1/quickstart.py b/language/cloud-client/v1/quickstart.py deleted file mode 100644 index 7c075a513b6..00000000000 --- a/language/cloud-client/v1/quickstart.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2016 Google Inc. All Rights Reserved. -# -# Licensed 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. - - -def run_quickstart(): - # [START language_quickstart] - # Imports the Google Cloud client library - # [START language_python_migration_imports] - from google.cloud import language - from google.cloud.language import enums - from google.cloud.language import types - # [END language_python_migration_imports] - - # Instantiates a client - # [START language_python_migration_client] - client = language.LanguageServiceClient() - # [END language_python_migration_client] - - # The text to analyze - text = u'Hello, world!' - document = types.Document( - content=text, - type=enums.Document.Type.PLAIN_TEXT) - - # Detects the sentiment of the text - sentiment = client.analyze_sentiment(document=document).document_sentiment - - print('Text: {}'.format(text)) - print('Sentiment: {}, {}'.format(sentiment.score, sentiment.magnitude)) - # [END language_quickstart] - - -if __name__ == '__main__': - run_quickstart() diff --git a/language/cloud-client/v1/quickstart_test.py b/language/cloud-client/v1/quickstart_test.py deleted file mode 100644 index bd9954c83bb..00000000000 --- a/language/cloud-client/v1/quickstart_test.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2016 Google Inc. All Rights Reserved. -# -# Licensed 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. - - -import quickstart - - -def test_quickstart(capsys): - quickstart.run_quickstart() - out, _ = capsys.readouterr() - assert 'Sentiment' in out diff --git a/language/cloud-client/v1/requirements-test.txt b/language/cloud-client/v1/requirements-test.txt deleted file mode 100644 index 7e460c8c866..00000000000 --- a/language/cloud-client/v1/requirements-test.txt +++ /dev/null @@ -1 +0,0 @@ -pytest==6.0.1 diff --git a/language/cloud-client/v1/requirements.txt b/language/cloud-client/v1/requirements.txt deleted file mode 100644 index 0c011f546e8..00000000000 --- a/language/cloud-client/v1/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -google-cloud-language==1.3.0 diff --git a/language/cloud-client/v1/resources/text.txt b/language/cloud-client/v1/resources/text.txt deleted file mode 100644 index 97a1cea02b7..00000000000 --- a/language/cloud-client/v1/resources/text.txt +++ /dev/null @@ -1 +0,0 @@ -President Obama is speaking at the White House. \ No newline at end of file diff --git a/language/cloud-client/v1/set_endpoint.py b/language/cloud-client/v1/set_endpoint.py deleted file mode 100644 index abc6f180a52..00000000000 --- a/language/cloud-client/v1/set_endpoint.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed 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. - - -def set_endpoint(): - """Change your endpoint""" - # [START language_set_endpoint] - # Imports the Google Cloud client library - from google.cloud import language - - client_options = {'api_endpoint': 'eu-language.googleapis.com:443'} - - # Instantiates a client - client = language.LanguageServiceClient(client_options=client_options) - # [END language_set_endpoint] - - # The text to analyze - document = language.types.Document( - content='Hello, world!', - type=language.enums.Document.Type.PLAIN_TEXT) - - # Detects the sentiment of the text - sentiment = client.analyze_sentiment(document=document).document_sentiment - - print('Sentiment: {}, {}'.format(sentiment.score, sentiment.magnitude)) - - -if __name__ == '__main__': - set_endpoint() diff --git a/language/cloud-client/v1/set_endpoint_test.py b/language/cloud-client/v1/set_endpoint_test.py deleted file mode 100644 index 7e124c36a93..00000000000 --- a/language/cloud-client/v1/set_endpoint_test.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed 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. - -import set_endpoint - - -def test_set_endpoint(capsys): - set_endpoint.set_endpoint() - - out, _ = capsys.readouterr() - assert 'Sentiment' in out diff --git a/language/generated-samples/v1/language_sentiment_text.py b/language/generated-samples/v1/language_sentiment_text.py deleted file mode 100644 index 10d17970df0..00000000000 --- a/language/generated-samples/v1/language_sentiment_text.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2018 Google LLC -# -# Licensed 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 -# -# https://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. - -# DO NOT EDIT! This is a generated sample ("Request", "analyze_sentiment") - -# To install the latest published package dependency, execute the following: -# pip install google-cloud-language - -import sys - -# [START language_sentiment_text] - -from google.cloud import language_v1 -from google.cloud.language_v1 import enums -import six - - -def sample_analyze_sentiment(content): - - client = language_v1.LanguageServiceClient() - - # content = 'Your text to analyze, e.g. Hello, world!' - - if isinstance(content, six.binary_type): - content = content.decode('utf-8') - - type_ = enums.Document.Type.PLAIN_TEXT - document = {'type': type_, 'content': content} - - response = client.analyze_sentiment(document) - sentiment = response.document_sentiment - print('Score: {}'.format(sentiment.score)) - print('Magnitude: {}'.format(sentiment.magnitude)) - - -# [END language_sentiment_text] - - -def main(): - # FIXME: Convert argv from strings to the correct types. - sample_analyze_sentiment(*sys.argv[1:]) - - -if __name__ == '__main__': - main() diff --git a/language/generated-samples/v1/language_sentiment_text_test.py b/language/generated-samples/v1/language_sentiment_text_test.py deleted file mode 100644 index e1876da2752..00000000000 --- a/language/generated-samples/v1/language_sentiment_text_test.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Google, Inc. -# -# Licensed 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. - -import language_sentiment_text - - -def test_analyze_sentiment_text_positive(capsys): - language_sentiment_text.sample_analyze_sentiment('Happy Happy Joy Joy') - out, _ = capsys.readouterr() - assert 'Score: 0.' in out - - -def test_analyze_sentiment_text_negative(capsys): - language_sentiment_text.sample_analyze_sentiment('Angry Angry Sad Sad') - out, _ = capsys.readouterr() - assert 'Score: -0.' in out diff --git a/language/generated-samples/v1/requirements-test.txt b/language/generated-samples/v1/requirements-test.txt deleted file mode 100644 index 7e460c8c866..00000000000 --- a/language/generated-samples/v1/requirements-test.txt +++ /dev/null @@ -1 +0,0 @@ -pytest==6.0.1 diff --git a/language/generated-samples/v1/requirements.txt b/language/generated-samples/v1/requirements.txt deleted file mode 100644 index 0c011f546e8..00000000000 --- a/language/generated-samples/v1/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -google-cloud-language==1.3.0 diff --git a/language/sentiment/README.md b/language/sentiment/README.md deleted file mode 100644 index 313817ef2fe..00000000000 --- a/language/sentiment/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# Introduction - -[![Open in Cloud Shell][shell_img]][shell_link] - -[shell_img]: http://gstatic.com/cloudssh/images/open-btn.png -[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=language/sentiment/README.md - -This sample contains the code referenced in the -[Sentiment Analysis Tutorial](http://cloud.google.com/natural-language/docs/sentiment-tutorial) -within the Google Cloud Natural Language API Documentation. A full walkthrough of this sample -is located within the documentation. - -This sample is a simple illustration of how to construct a sentiment analysis -request and process a response using the API. - -## Prerequisites - -Set up your -[Cloud Natural Language API project](https://cloud.google.com/natural-language/docs/getting-started#set_up_a_project) -, which includes: - -* Enabling the Natural Language API -* Setting up a service account -* Ensuring you've properly set up your `GOOGLE_APPLICATION_CREDENTIALS` for proper - authentication to the service. - -## Download the Code - -``` -$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git -$ cd python-docs-samples/language/sentiment -``` - -## Run the Code - -Open a sample folder, create a virtualenv, install dependencies, and run the sample: - -``` -$ virtualenv env -$ source env/bin/activate -(env)$ pip install -r requirements.txt -``` - -### Usage - -This sample provides four sample movie reviews which you can -provide to the sample on the command line. (You can also -pass your own text files.) - -``` -(env)$ python sentiment_analysis.py textfile.txt -Sentiment: score of -0.1 with magnitude of 6.7 -``` diff --git a/language/sentiment/requirements-test.txt b/language/sentiment/requirements-test.txt deleted file mode 100644 index 7e460c8c866..00000000000 --- a/language/sentiment/requirements-test.txt +++ /dev/null @@ -1 +0,0 @@ -pytest==6.0.1 diff --git a/language/sentiment/requirements.txt b/language/sentiment/requirements.txt deleted file mode 100644 index 0c011f546e8..00000000000 --- a/language/sentiment/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -google-cloud-language==1.3.0 diff --git a/language/sentiment/resources/mixed.txt b/language/sentiment/resources/mixed.txt deleted file mode 100644 index d4a42aa2928..00000000000 --- a/language/sentiment/resources/mixed.txt +++ /dev/null @@ -1,20 +0,0 @@ -I really wanted to love 'Bladerunner' but ultimately I couldn't get -myself to appreciate it fully. However, you may like it if you're into -science fiction, especially if you're interested in the philosophical -exploration of what it means to be human or machine. Some of the gizmos -like the flying cars and the Vouight-Kampff machine (which seemed very -steampunk), were quite cool. - -I did find the plot pretty slow and but the dialogue and action sequences -were good. Unlike most science fiction films, this one was mostly quiet, and -not all that much happened, except during the last 15 minutes. I didn't -understand why a unicorn was in the movie. The visual effects were fantastic, -however, and the musical score and overall mood was quite interesting. -A futurist Los Angeles that was both highly polished and also falling apart -reminded me of 'Outland.' Certainly, the style of the film made up for -many of its pedantic plot holes. - -If you want your sci-fi to be lasers and spaceships, 'Bladerunner' may -disappoint you. But if you want it to make you think, this movie may -be worth the money. - diff --git a/language/sentiment/resources/neg.txt b/language/sentiment/resources/neg.txt deleted file mode 100644 index 5dcbec0f8c5..00000000000 --- a/language/sentiment/resources/neg.txt +++ /dev/null @@ -1,4 +0,0 @@ -What was Hollywood thinking with this movie! I hated, -hated, hated it. BORING! I went afterwards and demanded my money back. -They refused. - diff --git a/language/sentiment/resources/neutral.txt b/language/sentiment/resources/neutral.txt deleted file mode 100644 index 89839ef25cf..00000000000 --- a/language/sentiment/resources/neutral.txt +++ /dev/null @@ -1,3 +0,0 @@ -I neither liked nor disliked this movie. Parts were interesting, but -overall I was left wanting more. The acting was pretty good. - diff --git a/language/sentiment/resources/pos.txt b/language/sentiment/resources/pos.txt deleted file mode 100644 index 5f211496775..00000000000 --- a/language/sentiment/resources/pos.txt +++ /dev/null @@ -1,11 +0,0 @@ -`Bladerunner` is often touted as one of the best science fiction films ever -made. Indeed, it satisfies many of the requisites for good sci-fi: a future -world with flying cars and humanoid robots attempting to rebel against their -creators. But more than anything, `Bladerunner` is a fantastic exploration -of the nature of what it means to be human. If we create robots which can -think, will they become human? And if they do, what makes us unique? Indeed, -how can we be sure we're not human in any case? `Bladerunner` explored -these issues before such movies as `The Matrix,' and did so intelligently. -The visual effects and score by Vangelis set the mood. See this movie -in a dark theatre to appreciate it fully. Highly recommended! - diff --git a/language/sentiment/sentiment_analysis.py b/language/sentiment/sentiment_analysis.py deleted file mode 100644 index 3b572bc2c94..00000000000 --- a/language/sentiment/sentiment_analysis.py +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright 2016, Google, Inc. -# Licensed 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. - -# [START language_sentiment_tutorial] -"""Demonstrates how to make a simple call to the Natural Language API.""" - -# [START language_sentiment_tutorial_imports] -import argparse - -from google.cloud import language -from google.cloud.language import enums -from google.cloud.language import types -# [END language_sentiment_tutorial_imports] - - -# [START language_sentiment_tutorial_print_result] -def print_result(annotations): - score = annotations.document_sentiment.score - magnitude = annotations.document_sentiment.magnitude - - for index, sentence in enumerate(annotations.sentences): - sentence_sentiment = sentence.sentiment.score - print('Sentence {} has a sentiment score of {}'.format( - index, sentence_sentiment)) - - print('Overall Sentiment: score of {} with magnitude of {}'.format( - score, magnitude)) - return 0 -# [END language_sentiment_tutorial_print_result] - - -# [START language_sentiment_tutorial_analyze_sentiment] -def analyze(movie_review_filename): - """Run a sentiment analysis request on text within a passed filename.""" - client = language.LanguageServiceClient() - - with open(movie_review_filename, 'r') as review_file: - # Instantiates a plain text document. - content = review_file.read() - - document = types.Document( - content=content, - type=enums.Document.Type.PLAIN_TEXT) - annotations = client.analyze_sentiment(document=document) - - # Print the results - print_result(annotations) -# [END language_sentiment_tutorial_analyze_sentiment] - - -# [START language_sentiment_tutorial_run_application] -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument( - 'movie_review_filename', - help='The filename of the movie review you\'d like to analyze.') - args = parser.parse_args() - - analyze(args.movie_review_filename) -# [END language_sentiment_tutorial_run_application] -# [END language_sentiment_tutorial] diff --git a/language/sentiment/sentiment_analysis_test.py b/language/sentiment/sentiment_analysis_test.py deleted file mode 100644 index 05d28ab2789..00000000000 --- a/language/sentiment/sentiment_analysis_test.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2016, Google, Inc. -# Licensed 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. - -import os -import re - -from sentiment_analysis import analyze - -RESOURCES = os.path.join(os.path.dirname(__file__), 'resources') - - -def test_pos(capsys): - analyze(os.path.join(RESOURCES, 'pos.txt')) - out, err = capsys.readouterr() - score = float(re.search('score of (.+?) with', out).group(1)) - magnitude = float(re.search('magnitude of (.+?)', out).group(1)) - assert score * magnitude > 0 - - -def test_neg(capsys): - analyze(os.path.join(RESOURCES, 'neg.txt')) - out, err = capsys.readouterr() - score = float(re.search('score of (.+?) with', out).group(1)) - magnitude = float(re.search('magnitude of (.+?)', out).group(1)) - assert score * magnitude < 0 - - -def test_mixed(capsys): - analyze(os.path.join(RESOURCES, 'mixed.txt')) - out, err = capsys.readouterr() - score = float(re.search('score of (.+?) with', out).group(1)) - assert score <= 0.3 - assert score >= -0.3 - - -def test_neutral(capsys): - analyze(os.path.join(RESOURCES, 'neutral.txt')) - out, err = capsys.readouterr() - magnitude = float(re.search('magnitude of (.+?)', out).group(1)) - assert magnitude <= 2.0 From 09f150cbf53d639e33b2ae23f774f865efcc9071 Mon Sep 17 00:00:00 2001 From: Harikumar Devandla Date: Thu, 1 Oct 2020 14:32:25 -0700 Subject: [PATCH 2/4] Add READMD.md --- language/README.md | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/language/README.md b/language/README.md index 5689d7c21ab..833c2f25cb6 100644 --- a/language/README.md +++ b/language/README.md @@ -1,15 +1,3 @@ -# Google Cloud Natural Language API examples +These samples have been moved. -[![Open in Cloud Shell][shell_img]][shell_link] - -[shell_img]: http://gstatic.com/cloudssh/images/open-btn.png -[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=language/README.md - -This directory contains Python examples that use the -[Google Cloud Natural Language API](https://cloud.google.com/natural-language/). - -- [api](api) has a simple command line tool that shows off the API's features. - -- [sentiment](sentiment) contains the [Sentiment Analysis - Tutorial](https://cloud.google.com/natural-language/docs/sentiment-tutorial) -code as used within the documentation. +https://github.com/googleapis/python-language/tree/master/samples \ No newline at end of file From 1c9d5e922b0a53ddcbb4aec89ef81b53c59c2ab1 Mon Sep 17 00:00:00 2001 From: Harikumar Devandla Date: Thu, 8 Oct 2020 16:43:27 -0700 Subject: [PATCH 3/4] remove files --- language/api/requirements.txt | 3 +++ language/classify_text/requirements.txt | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 language/api/requirements.txt create mode 100644 language/classify_text/requirements.txt diff --git a/language/api/requirements.txt b/language/api/requirements.txt new file mode 100644 index 00000000000..41f4cf40e0d --- /dev/null +++ b/language/api/requirements.txt @@ -0,0 +1,3 @@ +google-api-python-client==1.10.0 +google-auth==1.20.1 +google-auth-httplib2==0.0.4 diff --git a/language/classify_text/requirements.txt b/language/classify_text/requirements.txt new file mode 100644 index 00000000000..7ff166cc7e2 --- /dev/null +++ b/language/classify_text/requirements.txt @@ -0,0 +1,2 @@ +google-cloud-language==1.3.0 +numpy==1.19.1 From e4234cb575638736fb7fbd3461ac27e2e890baba Mon Sep 17 00:00:00 2001 From: Harikumar Devandla Date: Wed, 14 Oct 2020 13:21:07 -0700 Subject: [PATCH 4/4] remove files --- language/api/requirements.txt | 3 --- language/classify_text/requirements.txt | 2 -- 2 files changed, 5 deletions(-) delete mode 100644 language/api/requirements.txt delete mode 100644 language/classify_text/requirements.txt diff --git a/language/api/requirements.txt b/language/api/requirements.txt deleted file mode 100644 index be79e75b835..00000000000 --- a/language/api/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -google-api-python-client==1.12.2 -google-auth==1.22.1 -google-auth-httplib2==0.0.4 diff --git a/language/classify_text/requirements.txt b/language/classify_text/requirements.txt deleted file mode 100644 index de040ee00ca..00000000000 --- a/language/classify_text/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -google-cloud-language==1.3.0 -numpy==1.19.2