Skip to content

Commit

Permalink
feat: Add support for the v2 API (#11566)
Browse files Browse the repository at this point in the history
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people committed Aug 11, 2023
1 parent a971664 commit e0e5ce2
Show file tree
Hide file tree
Showing 40 changed files with 10,315 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/google-cloud-language/.flake8
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2020 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-language/CONTRIBUTING.rst
Expand Up @@ -236,7 +236,7 @@ We support:

Supported versions can be found in our ``noxfile.py`` `config`_.

.. _config: https://github.com/googleapis/google-cloud-python/blob/main/noxfile.py
.. _config: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-language/noxfile.py


**********
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-language/MANIFEST.in
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2020 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
27 changes: 14 additions & 13 deletions packages/google-cloud-language/README.rst
Expand Up @@ -36,21 +36,24 @@ In order to use this library, you first need to go through the following steps:
Installation
~~~~~~~~~~~~

Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
create isolated Python environments. The basic problem it addresses is one of
dependencies and versions, and indirectly permissions.
Install this library in a virtual environment using `venv`_. `venv`_ is a tool that
creates isolated Python environments. These isolated environments can have separate
versions of Python packages, which allows you to isolate one project's dependencies
from the dependencies of other projects.

With `virtualenv`_, it's possible to install this library without needing system
With `venv`_, it's possible to install this library without needing system
install permissions, and without clashing with the installed system
dependencies.

.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
.. _`venv`: https://docs.python.org/3/library/venv.html


Code samples and snippets
~~~~~~~~~~~~~~~~~~~~~~~~~

Code samples and snippets live in the `samples/` folder.
Code samples and snippets live in the `samples/`_ folder.

.. _samples/: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-language/samples


Supported Python Versions
Expand All @@ -77,21 +80,19 @@ Mac/Linux

.. code-block:: console
pip install virtualenv
virtualenv <your-env>
python3 -m venv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install google-cloud-language
pip install google-cloud-language
Windows
^^^^^^^

.. code-block:: console
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-cloud-language
py -m venv <your-env>
.\<your-env>\Scripts\activate
pip install google-cloud-language
Next Steps
~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-language/docs/conf.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2021 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
8 changes: 8 additions & 0 deletions packages/google-cloud-language/docs/index.rst
Expand Up @@ -22,6 +22,14 @@ API Reference
language_v1beta2/services
language_v1beta2/types

API Reference
-------------
.. toctree::
:maxdepth: 2

language_v2/services
language_v2/types


Changelog
---------
Expand Down
@@ -0,0 +1,6 @@
LanguageService
---------------------------------

.. automodule:: google.cloud.language_v2.services.language_service
:members:
:inherited-members:
6 changes: 6 additions & 0 deletions packages/google-cloud-language/docs/language_v2/services.rst
@@ -0,0 +1,6 @@
Services for Google Cloud Language v2 API
=========================================
.. toctree::
:maxdepth: 2

language_service
6 changes: 6 additions & 0 deletions packages/google-cloud-language/docs/language_v2/types.rst
@@ -0,0 +1,6 @@
Types for Google Cloud Language v2 API
======================================

.. automodule:: google.cloud.language_v2.types
:members:
:show-inheritance:
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
# Copyright 2023 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.
#
from google.cloud.language_v2 import gapic_version as package_version

__version__ = package_version.__version__


from .services.language_service import LanguageServiceAsyncClient, LanguageServiceClient
from .types.language_service import (
AnalyzeEntitiesRequest,
AnalyzeEntitiesResponse,
AnalyzeSentimentRequest,
AnalyzeSentimentResponse,
AnnotateTextRequest,
AnnotateTextResponse,
ClassificationCategory,
ClassifyTextRequest,
ClassifyTextResponse,
Document,
EncodingType,
Entity,
EntityMention,
ModerateTextRequest,
ModerateTextResponse,
Sentence,
Sentiment,
TextSpan,
)

__all__ = (
"LanguageServiceAsyncClient",
"AnalyzeEntitiesRequest",
"AnalyzeEntitiesResponse",
"AnalyzeSentimentRequest",
"AnalyzeSentimentResponse",
"AnnotateTextRequest",
"AnnotateTextResponse",
"ClassificationCategory",
"ClassifyTextRequest",
"ClassifyTextResponse",
"Document",
"EncodingType",
"Entity",
"EntityMention",
"LanguageServiceClient",
"ModerateTextRequest",
"ModerateTextResponse",
"Sentence",
"Sentiment",
"TextSpan",
)
@@ -0,0 +1,103 @@
{
"comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
"language": "python",
"libraryPackage": "google.cloud.language_v2",
"protoPackage": "google.cloud.language.v2",
"schema": "1.0",
"services": {
"LanguageService": {
"clients": {
"grpc": {
"libraryClient": "LanguageServiceClient",
"rpcs": {
"AnalyzeEntities": {
"methods": [
"analyze_entities"
]
},
"AnalyzeSentiment": {
"methods": [
"analyze_sentiment"
]
},
"AnnotateText": {
"methods": [
"annotate_text"
]
},
"ClassifyText": {
"methods": [
"classify_text"
]
},
"ModerateText": {
"methods": [
"moderate_text"
]
}
}
},
"grpc-async": {
"libraryClient": "LanguageServiceAsyncClient",
"rpcs": {
"AnalyzeEntities": {
"methods": [
"analyze_entities"
]
},
"AnalyzeSentiment": {
"methods": [
"analyze_sentiment"
]
},
"AnnotateText": {
"methods": [
"annotate_text"
]
},
"ClassifyText": {
"methods": [
"classify_text"
]
},
"ModerateText": {
"methods": [
"moderate_text"
]
}
}
},
"rest": {
"libraryClient": "LanguageServiceClient",
"rpcs": {
"AnalyzeEntities": {
"methods": [
"analyze_entities"
]
},
"AnalyzeSentiment": {
"methods": [
"analyze_sentiment"
]
},
"AnnotateText": {
"methods": [
"annotate_text"
]
},
"ClassifyText": {
"methods": [
"classify_text"
]
},
"ModerateText": {
"methods": [
"moderate_text"
]
}
}
}
}
}
}
}
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright 2023 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.
#
__version__ = "0.0.0" # {x-release-please-version}
@@ -0,0 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-language package uses inline types.
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright 2023 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.
#
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright 2023 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.
#
from .async_client import LanguageServiceAsyncClient
from .client import LanguageServiceClient

__all__ = (
"LanguageServiceClient",
"LanguageServiceAsyncClient",
)

0 comments on commit e0e5ce2

Please sign in to comment.