Natural Language Client#
Basic client for Google Cloud Natural Language API.
-
class
google.cloud.language.client.Client(credentials=None, http=None)[source]# Bases:
google.cloud.client.ClientClient to bundle configuration needed for API requests.
Parameters: - credentials (
OAuth2Credentials) – (Optional) The OAuth2 Credentials to use for the connection owned by this client. If not passed (and if nohttpobject is passed), falls back to the default inferred from the environment. - http (
httplib2.Httpor class that definesrequest().) – An optional HTTP object to make requests. If not passed, anhttpobject is created that is bound to thecredentialsfor the current object.
-
document_from_html(content, **kwargs)[source]# Create an HTML document bound to this client.
Parameters: Return type: Returns: An HTML document bound to this client.
Raises: TypeErrorifdoc_typeis passed as a keyword argument.
-
document_from_text(content, **kwargs)[source]# Create a plain text document bound to this client.
Parameters: Return type: Returns: A plain-text document bound to this client.
Raises: TypeErrorifdoc_typeis passed as a keyword argument.
-
document_from_url(gcs_url, doc_type='PLAIN_TEXT', **kwargs)[source]# Create a Cloud Storage document bound to this client.
Parameters: - gcs_url (str) – The URL of the Google Cloud Storage object
holding the content. Of the form
gs://{bucket}/{blob-name}. - doc_type (str) – (Optional) The type of text in the document.
Defaults to plain text. Can also be specified
as HTML via
HTML. - kwargs (dict) – Remaining keyword arguments to be passed along to the
Documentconstructor.
Return type: Returns: A document bound to this client.
- gcs_url (str) – The URL of the Google Cloud Storage object
holding the content. Of the form
- credentials (
Connection#
Basic connection for Google Cloud Natural Language API.
-
class
google.cloud.language.connection.Connection(credentials=None, http=None)[source]# Bases:
google.cloud.connection.JSONConnectionA connection to Google Cloud Natural Language JSON REST API.
-
API_BASE_URL= 'https://language.googleapis.com'# The base of the API call URL.
-
API_URL_TEMPLATE= '{api_base_url}/{api_version}/documents:{path}'# A template for the URL of a particular API call.
-
API_VERSION= 'v1beta1'# The version of the API, used in building the API call’s URL.
-
SCOPE= ('https://www.googleapis.com/auth/cloud-platform',)# The scopes required for authenticating as an API consumer.
-