v1beta2. LanguageServiceClient
Provides text analysis operations such as sentiment analysis and entity recognition.
Constructor
LanguageServiceClient
new LanguageServiceClient(options)
Construct an instance of LanguageServiceClient.
Parameter |
|||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Optional object The configuration object. See the subsequent parameters for more details. Values in
|
Properties
port
The port for this API service.
scopes
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
The DNS address for this API service.
Methods
analyzeEntities
analyzeEntities(request, options, callback) returns Promise
Finds named entities (currently proper names and common nouns) in the text along with entity types, salience, mentions for each entity, and other properties.
Parameter |
|||||||
---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is an object representing AnalyzeEntitiesResponse. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is an object representing AnalyzeEntitiesResponse. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const language = require('@google-cloud/language');
var client = new language.v1beta2.LanguageServiceClient({
// optional auth parameters.
});
var document = {};
client.analyzeEntities({document: document})
.then(responses => {
var response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
analyzeEntitySentiment
analyzeEntitySentiment(request, options, callback) returns Promise
Finds entities, similar to AnalyzeEntities in the text and analyzes sentiment associated with each entity and its mentions.
Parameter |
|||||||
---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is an object representing AnalyzeEntitySentimentResponse. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is an object representing AnalyzeEntitySentimentResponse. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const language = require('@google-cloud/language');
var client = new language.v1beta2.LanguageServiceClient({
// optional auth parameters.
});
var document = {};
client.analyzeEntitySentiment({document: document})
.then(responses => {
var response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
analyzeSentiment
analyzeSentiment(request, options, callback) returns Promise
Analyzes the sentiment of the provided text.
Parameter |
|||||||
---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is an object representing AnalyzeSentimentResponse. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is an object representing AnalyzeSentimentResponse. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const language = require('@google-cloud/language');
var client = new language.v1beta2.LanguageServiceClient({
// optional auth parameters.
});
var document = {};
client.analyzeSentiment({document: document})
.then(responses => {
var response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
analyzeSyntax
analyzeSyntax(request, options, callback) returns Promise
Analyzes the syntax of the text and provides sentence boundaries and tokenization along with part of speech tags, dependency trees, and other properties.
Parameter |
|||||||
---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is an object representing AnalyzeSyntaxResponse. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is an object representing AnalyzeSyntaxResponse. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const language = require('@google-cloud/language');
var client = new language.v1beta2.LanguageServiceClient({
// optional auth parameters.
});
var document = {};
client.analyzeSyntax({document: document})
.then(responses => {
var response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
annotateText
annotateText(request, options, callback) returns Promise
A convenience method that provides all syntax, sentiment, entity, and classification features in one call.
Parameter |
|||||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is an object representing AnnotateTextResponse. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is an object representing AnnotateTextResponse. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const language = require('@google-cloud/language');
var client = new language.v1beta2.LanguageServiceClient({
// optional auth parameters.
});
var document = {};
var features = {};
var request = {
document: document,
features: features,
};
client.annotateText(request)
.then(responses => {
var response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
classifyText
classifyText(request, options, callback) returns Promise
Classifies a document into categories.
Parameter |
|||||
---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is an object representing ClassifyTextResponse. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is an object representing ClassifyTextResponse. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const language = require('@google-cloud/language');
var client = new language.v1beta2.LanguageServiceClient({
// optional auth parameters.
});
var document = {};
client.classifyText({document: document})
.then(responses => {
var response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
getProjectId
getProjectId(callback)
Return the project ID used by this class.
Parameter |
|
---|---|
callback |
function(Error, string) the callback to be called with the current project Id. |