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.
-
Read Prerequisites and How to run a sample first.
-
Install dependencies:
With npm:
npm install
With yarn:
yarn install
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
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
View the README.
-
Set the GCLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS environment variables.
-
Run the tests:
With npm:
npm test
With yarn:
yarn test