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.
-
Please follow the Set Up Your Project steps in the Quickstart doc to create a project and enable the Cloud Natural Language API.
-
Read Prerequisites and How to run a sample first.
-
Install dependencies:
npm install
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"
}