Skip to content
Node.js client for Google Cloud Natural Language: Derive insights from unstructured text using Google machine learning.
Branch: master
Clone or download
yoshi-automation and JustinBeckwith chore: release 3.2.2 (#264)
* updated CHANGELOG.md

* updated package.json

* updated samples/package.json
Latest commit d8efd23 Jun 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github chore: move CONTRIBUTING.md to root (#199) Feb 7, 2019
.kokoro build: remove verbose logging from test scripts (#253) May 29, 2019
protos/google/cloud/language fix: improve docstrings, and add more field validation (#224) Apr 4, 2019
samples chore: release 3.2.2 (#264) Jun 14, 2019
smoke-test chore: sync gapic files Jan 17, 2019
src feat: support apiEndpoint override in client constructor (#256) Jun 5, 2019
system-test chore: udpate lint configs (#158) Nov 9, 2018
test feat: support apiEndpoint override in client constructor (#256) Jun 5, 2019
.eslintignore chore: update nyc and eslint configs (#182) Dec 11, 2018
.eslintrc.yml Enable prefer-const in the eslint config (#121) Sep 20, 2018
.gitignore feat: add .repo-metadata.json and generate README (#255) Jun 6, 2019
.jsdoc.js build: check broken links in generated docs (#187) Jan 15, 2019
.nycrc build: ignore proto files in test coverage (#252) May 28, 2019
.prettierignore Migrate to the nodejs-language repo. (#7) Oct 13, 2017
.prettierrc Migrate to the nodejs-language repo. (#7) Oct 13, 2017
.readme-partials.yml feat: add .repo-metadata.json and generate README (#255) Jun 6, 2019
.repo-metadata.json fix(docs): move to new client docs URL (#263) Jun 13, 2019
CHANGELOG.md chore: release 3.2.2 (#264) Jun 14, 2019
CODE_OF_CONDUCT.md Migrate to the nodejs-language repo. (#7) Oct 13, 2017
CONTRIBUTING.md docs: update links in contrib guide (#206) Feb 14, 2019
LICENSE docs: update the readme (#172) Dec 4, 2018
README.md fix(docs): move to new client docs URL (#263) Jun 13, 2019
codecov.yaml Update kokoro config (#132) Oct 2, 2018
package.json chore: release 3.2.2 (#264) Jun 14, 2019
renovate.json chore: ignore package-lock.json (#93) Aug 7, 2018
synth.metadata docs: add v1 and v1beta2 samples to README (#260) Jun 11, 2019
synth.py chore: udpate lint configs (#158) Nov 9, 2018

README.md

Google Cloud Platform logo

Natural Language: Node.js Client

release level npm version codecov

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 more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Natural Language API.
  4. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/language

Using the client library

async function quickstart() {
  // Imports the Google Cloud client library
  const language = require('@google-cloud/language');

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

  // The text to analyze
  const text = 'Hello, world!';

  const document = {
    content: text,
    type: 'PLAIN_TEXT',
  };

  // Detects the sentiment of the text
  const [result] = await client.analyzeSentiment({document: document});
  const sentiment = result.documentSentiment;

  console.log(`Text: ${text}`);
  console.log(`Sentiment score: ${sentiment.score}`);
  console.log(`Sentiment magnitude: ${sentiment.magnitude}`);
}

Samples

Samples are in the samples/ directory. The samples' README.md has instructions for running the samples.

Sample Source Code Try it
Analyze v1 source code Open in Cloud Shell
Analyze v1beta2 source code Open in Cloud Shell
Automl Natural Language Dataset source code Open in Cloud Shell
Automl Natural Language Model source code Open in Cloud Shell
Automl Natural Language Predict source code Open in Cloud Shell
Quickstart source code Open in Cloud Shell

The Natural Language Node.js Client API Reference documentation also contains samples.

Versioning

This library follows Semantic Versioning.

This library is considered to be General Availability (GA). This means it is stable; the code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against GA libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

License

Apache Version 2.0

See LICENSE

You can’t perform that action at this time.