Skip to content

Latest commit

 

History

History
 
 

language

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Google Cloud Platform logo

Google Cloud Natural Language API Node.js Samples

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

Table of Contents

Setup

  1. Please follow the Set Up Your Project steps in the Quickstart doc to create a project and enable the Cloud Natural Language API.

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

  3. Install dependencies:

     npm install
    

Samples

Analyze

View the source code.

Run the sample:

Usage: node analyze <sentiment|entities|syntax> <text>

For example, the following command returns all entities found in the text:

Example:

node analyze entities "President Obama is speaking at the White House."

{
  "entities": [
    {
      "name": "Obama",
      "type": "PERSON",
      "metadata": {
        "wikipedia_url": "http://en.wikipedia.org/wiki/Barack_Obama"
      },
      "salience": 0.84503114,
      "mentions": [
        {
          "text": {
            "content": "Obama",
            "beginOffset": 10
          }
        }
      ]
    },
    {
      "name": "White House",
      "type": "LOCATION",
      "metadata": {
        "wikipedia_url": "http://en.wikipedia.org/wiki/White_House"
      },
      "salience": 0.15496887,
      "mentions": [
        {
          "text": {
            "content": "White House",
            "beginOffset": 35
          }
        }
      ]
    }
  ],
  "language": "en"
}