Skip to content

Latest commit

 

History

History
124 lines (83 loc) · 4.93 KB

README.md

File metadata and controls

124 lines (83 loc) · 4.93 KB

Google Cloud Platform logo

Google Cloud Natural Language API Node.js Samples

Build

Cloud Natural Language API provides natural language understanding technologies to developers, including sentiment analysis, entity analysis, and syntax analysis. This API is part of the larger Cloud Machine Learning API family.

Table of Contents

Setup

  1. Read Prerequisites and How to run a sample first.

  2. Install dependencies:

    With npm:

    npm install
    

    With yarn:

    yarn install
    

Samples

Analyze v1

View the documentation or the source code.

Usage: node analyze.v1.js --help

Commands:
  sentiment-text <text>                   Detects sentiment of a string.
  sentiment-file <bucketName> <fileName>  Detects sentiment in a file in Google Cloud Storage.
  entities-text <text>                    Detects entities in a string.
  entities-file <bucketName> <fileName>   Detects entities in a file in Google Cloud Storage.
  syntax-text <text>                      Detects syntax of a string.
  syntax-file <bucketName> <fileName>     Detects syntax in a file in Google Cloud Storage.

Options:
  --help  Show help                                                                                            [boolean]

Examples:
  node analyze.v1.js sentiment-text "President Obama is speaking at the White House."
  node analyze.v1.js sentiment-file my-bucket file.txt          Detects sentiment in gs://my-bucket/file.txt
  node analyze.v1.js entities-text "President Obama is speaking at the White House."
  node analyze.v1.js entities-file my-bucket file.txt           Detects entities in gs://my-bucket/file.txt
  node analyze.v1.js syntax-text "President Obama is speaking at the White House."
  node analyze.v1.js syntax-file my-bucket file.txt             Detects syntax in gs://my-bucket/file.txt

For more information, see https://cloud.google.com/natural-language/docs

Analyze v1beta2

View the documentation or the source code.

Usage: node analyze.v1beta2.js --help

Commands:
  sentiment-text <text>                          Detects sentiment of a string.
  sentiment-file <bucketName> <fileName>         Detects sentiment in a file in Google Cloud Storage.
  entities-text <text>                           Detects entities in a string.
  entities-file <bucketName> <fileName>          Detects entities in a file in Google Cloud Storage.
  syntax-text <text>                             Detects syntax of a string.
  syntax-file <bucketName> <fileName>            Detects syntax in a file in Google Cloud Storage.
  entity-sentiment-text <text>                   Detects sentiment of the entities in a string.
  entity-sentiment-file <bucketName> <fileName>  Detects sentiment of the entities in a file in Google Cloud Storage.

Options:
  --help  Show help                                                                                            [boolean]

Examples:
  node analyze.v1beta2.js sentiment-text "President Obama is speaking at the White House."
  node analyze.v1beta2.js sentiment-file my-bucket file.txt     Detects sentiment in gs://my-bucket/file.txt
  node analyze.v1beta2.js entities-text "President Obama is speaking at the White House."
  node analyze.v1beta2.js entities-file my-bucket file.txt      Detects entities in gs://my-bucket/file.txt
  node analyze.v1beta2.js syntax-text "President Obama is speaking at the White House."
  node analyze.v1beta2.js syntax-file my-bucket file.txt        Detects syntax in gs://my-bucket/file.txt
  node analyze.v1beta2.js entity-sentiment-text "President Obama is speaking at the White House."
  node analyze.v1beta2.js entity-sentiment-file my-bucket       Detects sentiment of entities in gs://my-bucket/file.txt
  file.txt

For more information, see https://cloud.google.com/natural-language/docs

Slack Bot

View the README.

Running the tests

  1. Set the GCLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS environment variables.

  2. Run the tests:

    With npm:

    npm test
    

    With yarn:

    yarn test