How to use the @google-cloud/language.v1beta2.LanguageServiceClient function in @google-cloud/language

To help you get started, we’ve selected a few @google-cloud/language examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-language / samples / analyze.v1beta2.js View on Github external
async function analyzeSyntaxOfText(text) {
  // [START language_syntax_string]
  // Imports the Google Cloud client library
  const language = require('@google-cloud/language').v1beta2;

  // Creates a v1beta2 client
  const client = new language.LanguageServiceClient();

  /**
   * TODO(developer): Uncomment the following line to run this code.
   */
  // const text = 'Your text to analyze, e.g. Hello, world!';

  // Prepares a document, representing the provided text
  const document = {
    content: text,
    type: 'PLAIN_TEXT',
  };

  // Detects syntax in the document
  const [syntax] = await client.analyzeSyntax({document});

  console.log('Parts of speech:');
github googleapis / nodejs-language / samples / analyze.v1beta2.js View on Github external
async function analyzeSentimentOfText(text) {
  // [START language_sentiment_string]
  // Imports the Google Cloud client library
  const language = require('@google-cloud/language').v1beta2;

  // Creates a v1beta2 client
  const client = new language.LanguageServiceClient();

  /**
   * TODO(developer): Uncomment the following line to run this code.
   */
  // const text = 'Your text to analyze, e.g. Hello, world!';

  // Prepares a document, representing the provided text
  const document = {
    content: text,
    type: 'PLAIN_TEXT',
  };

  // Detects the sentiment of the document
  const [result] = await client.analyzeSentiment({document});
  const sentiment = result.documentSentiment;
  console.log(`Document sentiment:`);
github googleapis / nodejs-language / samples / analyze.v1beta2.js View on Github external
async function classifyTextInFile(bucketName, fileName) {
  // [START language_classify_file]
  // Imports the Google Cloud client library
  const language = require('@google-cloud/language').v1beta2;

  // Creates a v1beta2 client
  const client = new language.LanguageServiceClient();

  /**
   * TODO(developer): Uncomment the following lines to run this code
   */
  // const bucketName = 'Your bucket name, e.g. my-bucket';
  // const fileName = 'Your file name, e.g. my-file.txt';

  // Prepares a document, representing a text file in Cloud Storage
  const document = {
    gcsContentUri: `gs://${bucketName}/${fileName}`,
    type: 'PLAIN_TEXT',
  };

  // Classifies text in the document
  const [classification] = await client.classifyText({document});
  console.log('Categories:');
github googleapis / nodejs-language / samples / analyze.v1beta2.js View on Github external
async function classifyTextOfText(text) {
  // [START language_classify_string]
  // Imports the Google Cloud client library
  const language = require('@google-cloud/language').v1beta2;

  // Creates a v1beta2 client
  const client = new language.LanguageServiceClient();

  /**
   * TODO(developer): Uncomment the following line to run this code.
   */
  // const text = 'Your text to analyze, e.g. Hello, world!';

  // Prepares a document, representing the provided text
  const document = {
    content: text,
    type: 'PLAIN_TEXT',
  };

  // Classifies text in the document
  const [classification] = await client.classifyText({document});
  console.log('Categories:');
  classification.categories.forEach(category => {
github googleapis / nodejs-language / samples / analyze.v1beta2.js View on Github external
async function analyzeSentimentInFile(bucketName, fileName) {
  // [START language_sentiment_file]
  // Imports the Google Cloud client library
  const language = require('@google-cloud/language').v1beta2;

  // Creates a v1beta2 client
  const client = new language.LanguageServiceClient();

  /**
   * TODO(developer): Uncomment the following lines to run this code
   */
  // const bucketName = 'Your bucket name, e.g. my-bucket';
  // const fileName = 'Your file name, e.g. my-file.txt';

  // Prepares a document, representing a text file in Cloud Storage
  const document = {
    gcsContentUri: `gs://${bucketName}/${fileName}`,
    type: 'PLAIN_TEXT',
  };

  // Detects the sentiment of the document
  const [result] = await client.analyzeSentiment({document});
  const sentiment = result.documentSentiment;
github googleapis / nodejs-language / samples / analyze.v1beta2.js View on Github external
async function analyzeEntitiesInFile(bucketName, fileName) {
  // [START language_entities_file]
  // Imports the Google Cloud client library
  const language = require('@google-cloud/language').v1beta2;

  // Creates a v1beta2 client
  const client = new language.LanguageServiceClient();

  /**
   * TODO(developer): Uncomment the following lines to run this code
   */
  // const bucketName = 'Your bucket name, e.g. my-bucket';
  // const fileName = 'Your file name, e.g. my-file.txt';

  // Prepares a document, representing a text file in Cloud Storage
  const document = {
    gcsContentUri: `gs://${bucketName}/${fileName}`,
    type: 'PLAIN_TEXT',
  };

  // Detects entities in the document
  const [result] = await client.analyzeEntities({document});
  const entities = result.entities;
github googleapis / nodejs-language / samples / analyze.v1beta2.js View on Github external
async function analyzeSyntaxInFile(bucketName, fileName) {
  // [START language_syntax_file]
  // Imports the Google Cloud client library
  const language = require('@google-cloud/language').v1beta2;

  // Creates a v1beta2 client
  const client = new language.LanguageServiceClient();

  /**
   * TODO(developer): Uncomment the following lines to run this code
   */
  // const bucketName = 'Your bucket name, e.g. my-bucket';
  // const fileName = 'Your file name, e.g. my-file.txt';

  // Prepares a document, representing a text file in Cloud Storage
  const document = {
    gcsContentUri: `gs://${bucketName}/${fileName}`,
    type: 'PLAIN_TEXT',
  };

  // Detects syntax in the document
  const [syntax] = await client.analyzeSyntax({document});
github googleapis / nodejs-language / samples / analyze.v1beta2.js View on Github external
async function analyzeEntitiesOfText(text) {
  // [START language_entities_string]
  // Imports the Google Cloud client library
  const language = require('@google-cloud/language').v1beta2;

  // Creates a v1beta2 client
  const client = new language.LanguageServiceClient();

  /**
   * TODO(developer): Uncomment the following line to run this code.
   */
  // const text = 'Your text to analyze, e.g. Hello, world!';

  // Prepares a document, representing the provided text
  const document = {
    content: text,
    type: 'PLAIN_TEXT',
  };

  // Detects entities in the document
  const [result] = await client.analyzeEntities({document});
  const entities = result.entities;

@google-cloud/language

Google Cloud Natural Language API client for Node.js

Apache-2.0
Latest version published 3 days ago

Package Health Score

92 / 100
Full package analysis