# Cloud Natural Language V2 API - Class Google::Cloud::Language::V2::LanguageService::Rest::Client (v1.5.0)

1.5.0 (latest) 1.4.0 1.3.0 1.2.1 1.1.0 1.0.1 0.7.0 0.6.0 0.5.1 0.4.0 0.3.2 0.2.0 0.1.0 Reference documentation and code samples for the Cloud Natural Language V2 API class Google::Cloud::Language::V2::LanguageService::Rest::Client.

REST client for the LanguageService service.


<br />

Provides text analysis operations such as sentiment analysis and entity
recognition.

## Inherits

- Object

## Methods

### .configure

    def self.configure() { |config| ... } -> Client::Configuration

Configure the LanguageService Client class.


<br />

See [Configuration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-LanguageService-Rest-Client-Configuration "Google::Cloud::Language::V2::LanguageService::Rest::Client::Configuration (class)")
for a description of the configuration fields.
**Yields**

- (config) --- Configure the Client client.
**Yield Parameter**

- **config** ([Client::Configuration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-LanguageService-Rest-Client-Configuration))
**Returns**

- ([Client::Configuration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-LanguageService-Rest-Client-Configuration))
**Example**

```ruby
# Modify the configuration for all LanguageService clients
::Google::Cloud::Language::V2::LanguageService::Rest::Client.configure do |config|
  config.timeout = 10.0
end
```

### #analyze_entities

    def analyze_entities(request, options = nil) -> ::Google::Cloud::Language::V2::AnalyzeEntitiesResponse
    def analyze_entities(document: nil, encoding_type: nil) -> ::Google::Cloud::Language::V2::AnalyzeEntitiesResponse

Finds named entities (currently proper names and common nouns) in the text
along with entity types, probability, mentions for each entity, and
other properties.
**Overloads**

    def analyze_entities(request, options = nil) -> ::Google::Cloud::Language::V2::AnalyzeEntitiesResponse

Pass arguments to `analyze_entities` via a request object, either of type [AnalyzeEntitiesRequest](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnalyzeEntitiesRequest "Google::Cloud::Language::V2::AnalyzeEntitiesRequest (class)") or an equivalent Hash. **Parameters**

- **request** ([::Google::Cloud::Language::V2::AnalyzeEntitiesRequest](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnalyzeEntitiesRequest), ::Hash) --- A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- **options** (::Gapic::CallOptions, ::Hash) --- Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

    def analyze_entities(document: nil, encoding_type: nil) -> ::Google::Cloud::Language::V2::AnalyzeEntitiesResponse

Pass arguments to `analyze_entities` via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above). **Parameters**

- **document** ([::Google::Cloud::Language::V2::Document](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-Document), ::Hash) --- Required. Input document.
- **encoding_type** ([::Google::Cloud::Language::V2::EncodingType](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-EncodingType)) --- The encoding type used by the API to calculate offsets.
**Yields**

- (result, operation) --- Access the result along with the TransportOperation object
**Yield Parameters**

- **result** ([::Google::Cloud::Language::V2::AnalyzeEntitiesResponse](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnalyzeEntitiesResponse))
- **operation** (::Gapic::Rest::TransportOperation)
**Returns**

- ([::Google::Cloud::Language::V2::AnalyzeEntitiesResponse](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnalyzeEntitiesResponse))
**Raises**

- (::Google::Cloud::Error) --- if the REST call is aborted.
**Example**

Basic example

```ruby
require "google/cloud/language/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Language::V2::LanguageService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Language::V2::AnalyzeEntitiesRequest.new

# Call the analyze_entities method.
result = client.analyze_entities request

# The returned object is of type Google::Cloud::Language::V2::AnalyzeEntitiesResponse.
p result
```

### #analyze_sentiment

    def analyze_sentiment(request, options = nil) -> ::Google::Cloud::Language::V2::AnalyzeSentimentResponse
    def analyze_sentiment(document: nil, encoding_type: nil) -> ::Google::Cloud::Language::V2::AnalyzeSentimentResponse

Analyzes the sentiment of the provided text.
**Overloads**

    def analyze_sentiment(request, options = nil) -> ::Google::Cloud::Language::V2::AnalyzeSentimentResponse

Pass arguments to `analyze_sentiment` via a request object, either of type [AnalyzeSentimentRequest](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnalyzeSentimentRequest "Google::Cloud::Language::V2::AnalyzeSentimentRequest (class)") or an equivalent Hash. **Parameters**

- **request** ([::Google::Cloud::Language::V2::AnalyzeSentimentRequest](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnalyzeSentimentRequest), ::Hash) --- A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- **options** (::Gapic::CallOptions, ::Hash) --- Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

    def analyze_sentiment(document: nil, encoding_type: nil) -> ::Google::Cloud::Language::V2::AnalyzeSentimentResponse

Pass arguments to `analyze_sentiment` via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above). **Parameters**

- **document** ([::Google::Cloud::Language::V2::Document](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-Document), ::Hash) --- Required. Input document.
- **encoding_type** ([::Google::Cloud::Language::V2::EncodingType](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-EncodingType)) --- The encoding type used by the API to calculate sentence offsets.
**Yields**

- (result, operation) --- Access the result along with the TransportOperation object
**Yield Parameters**

- **result** ([::Google::Cloud::Language::V2::AnalyzeSentimentResponse](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnalyzeSentimentResponse))
- **operation** (::Gapic::Rest::TransportOperation)
**Returns**

- ([::Google::Cloud::Language::V2::AnalyzeSentimentResponse](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnalyzeSentimentResponse))
**Raises**

- (::Google::Cloud::Error) --- if the REST call is aborted.
**Example**

Basic example

```ruby
require "google/cloud/language/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Language::V2::LanguageService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Language::V2::AnalyzeSentimentRequest.new

# Call the analyze_sentiment method.
result = client.analyze_sentiment request

# The returned object is of type Google::Cloud::Language::V2::AnalyzeSentimentResponse.
p result
```

### #annotate_text

    def annotate_text(request, options = nil) -> ::Google::Cloud::Language::V2::AnnotateTextResponse
    def annotate_text(document: nil, features: nil, encoding_type: nil) -> ::Google::Cloud::Language::V2::AnnotateTextResponse

A convenience method that provides all features in one call.
**Overloads**

    def annotate_text(request, options = nil) -> ::Google::Cloud::Language::V2::AnnotateTextResponse

Pass arguments to `annotate_text` via a request object, either of type [AnnotateTextRequest](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnnotateTextRequest "Google::Cloud::Language::V2::AnnotateTextRequest (class)") or an equivalent Hash. **Parameters**

- **request** ([::Google::Cloud::Language::V2::AnnotateTextRequest](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnnotateTextRequest), ::Hash) --- A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- **options** (::Gapic::CallOptions, ::Hash) --- Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

    def annotate_text(document: nil, features: nil, encoding_type: nil) -> ::Google::Cloud::Language::V2::AnnotateTextResponse

Pass arguments to `annotate_text` via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above). **Parameters**

- **document** ([::Google::Cloud::Language::V2::Document](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-Document), ::Hash) --- Required. Input document.
- **features** ([::Google::Cloud::Language::V2::AnnotateTextRequest::Features](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnnotateTextRequest-Features), ::Hash) --- Required. The enabled features.
- **encoding_type** ([::Google::Cloud::Language::V2::EncodingType](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-EncodingType)) --- The encoding type used by the API to calculate offsets.
**Yields**

- (result, operation) --- Access the result along with the TransportOperation object
**Yield Parameters**

- **result** ([::Google::Cloud::Language::V2::AnnotateTextResponse](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnnotateTextResponse))
- **operation** (::Gapic::Rest::TransportOperation)
**Returns**

- ([::Google::Cloud::Language::V2::AnnotateTextResponse](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-AnnotateTextResponse))
**Raises**

- (::Google::Cloud::Error) --- if the REST call is aborted.
**Example**

Basic example

```ruby
require "google/cloud/language/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Language::V2::LanguageService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Language::V2::AnnotateTextRequest.new

# Call the annotate_text method.
result = client.annotate_text request

# The returned object is of type Google::Cloud::Language::V2::AnnotateTextResponse.
p result
```

### #classify_text

    def classify_text(request, options = nil) -> ::Google::Cloud::Language::V2::ClassifyTextResponse
    def classify_text(document: nil) -> ::Google::Cloud::Language::V2::ClassifyTextResponse

Classifies a document into categories.
**Overloads**

    def classify_text(request, options = nil) -> ::Google::Cloud::Language::V2::ClassifyTextResponse

Pass arguments to `classify_text` via a request object, either of type [ClassifyTextRequest](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-ClassifyTextRequest "Google::Cloud::Language::V2::ClassifyTextRequest (class)") or an equivalent Hash. **Parameters**

- **request** ([::Google::Cloud::Language::V2::ClassifyTextRequest](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-ClassifyTextRequest), ::Hash) --- A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- **options** (::Gapic::CallOptions, ::Hash) --- Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

    def classify_text(document: nil) -> ::Google::Cloud::Language::V2::ClassifyTextResponse

Pass arguments to `classify_text` via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above). **Parameter**

- **document** ([::Google::Cloud::Language::V2::Document](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-Document), ::Hash) --- Required. Input document.
**Yields**

- (result, operation) --- Access the result along with the TransportOperation object
**Yield Parameters**

- **result** ([::Google::Cloud::Language::V2::ClassifyTextResponse](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-ClassifyTextResponse))
- **operation** (::Gapic::Rest::TransportOperation)
**Returns**

- ([::Google::Cloud::Language::V2::ClassifyTextResponse](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-ClassifyTextResponse))
**Raises**

- (::Google::Cloud::Error) --- if the REST call is aborted.
**Example**

Basic example

```ruby
require "google/cloud/language/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Language::V2::LanguageService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Language::V2::ClassifyTextRequest.new

# Call the classify_text method.
result = client.classify_text request

# The returned object is of type Google::Cloud::Language::V2::ClassifyTextResponse.
p result
```

### #configure

    def configure() { |config| ... } -> Client::Configuration

Configure the LanguageService Client instance.


The configuration is set to the derived mode, meaning that values can be changed,
but structural changes (adding new fields, etc.) are not allowed. Structural changes
should be made on [Client.configure](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-LanguageService-Rest-Client#Google__Cloud__Language__V2__LanguageService__Rest__Client_configure_class_ "Google::Cloud::Language::V2::LanguageService::Rest::Client.configure (method)").

<br />

See [Configuration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-LanguageService-Rest-Client-Configuration "Google::Cloud::Language::V2::LanguageService::Rest::Client::Configuration (class)")
for a description of the configuration fields.
**Yields**

- (config) --- Configure the Client client.
**Yield Parameter**

- **config** ([Client::Configuration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-LanguageService-Rest-Client-Configuration))
**Returns**

- ([Client::Configuration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-LanguageService-Rest-Client-Configuration))

### #initialize

    def initialize() { |config| ... } -> Client

Create a new LanguageService REST client object.
**Yields**

- (config) --- Configure the LanguageService client.
**Yield Parameter**

- **config** ([Client::Configuration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-LanguageService-Rest-Client-Configuration))
**Returns**

- ([Client](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-LanguageService-Rest-Client)) --- a new instance of Client
**Example**

```ruby
# Create a client using the default configuration
client = ::Google::Cloud::Language::V2::LanguageService::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Language::V2::LanguageService::Rest::Client.new do |config|
  config.timeout = 10.0
end
```

### #logger

    def logger() -> Logger

The logger used for request/response debug logging.
**Returns**

- (Logger)

### #moderate_text

    def moderate_text(request, options = nil) -> ::Google::Cloud::Language::V2::ModerateTextResponse
    def moderate_text(document: nil, model_version: nil) -> ::Google::Cloud::Language::V2::ModerateTextResponse

Moderates a document for harmful and sensitive categories.
**Overloads**

    def moderate_text(request, options = nil) -> ::Google::Cloud::Language::V2::ModerateTextResponse

Pass arguments to `moderate_text` via a request object, either of type [ModerateTextRequest](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-ModerateTextRequest "Google::Cloud::Language::V2::ModerateTextRequest (class)") or an equivalent Hash. **Parameters**

- **request** ([::Google::Cloud::Language::V2::ModerateTextRequest](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-ModerateTextRequest), ::Hash) --- A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- **options** (::Gapic::CallOptions, ::Hash) --- Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

    def moderate_text(document: nil, model_version: nil) -> ::Google::Cloud::Language::V2::ModerateTextResponse

Pass arguments to `moderate_text` via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above). **Parameters**

- **document** ([::Google::Cloud::Language::V2::Document](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-Document), ::Hash) --- Required. Input document.
- **model_version** ([::Google::Cloud::Language::V2::ModerateTextRequest::ModelVersion](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-ModerateTextRequest-ModelVersion)) --- Optional. The model version to use for ModerateText.
**Yields**

- (result, operation) --- Access the result along with the TransportOperation object
**Yield Parameters**

- **result** ([::Google::Cloud::Language::V2::ModerateTextResponse](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-ModerateTextResponse))
- **operation** (::Gapic::Rest::TransportOperation)
**Returns**

- ([::Google::Cloud::Language::V2::ModerateTextResponse](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-language-v2/latest/Google-Cloud-Language-V2-ModerateTextResponse))
**Raises**

- (::Google::Cloud::Error) --- if the REST call is aborted.
**Example**

Basic example

```ruby
require "google/cloud/language/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Language::V2::LanguageService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Language::V2::ModerateTextRequest.new

# Call the moderate_text method.
result = client.moderate_text request

# The returned object is of type Google::Cloud::Language::V2::ModerateTextResponse.
p result
```

### #universe_domain

    def universe_domain() -> String

The effective universe domain
**Returns**

- (String)