Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
docs: update the readme (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Dec 5, 2018
1 parent f39a3d8 commit c57b5df
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 124 deletions.
28 changes: 28 additions & 0 deletions .cloud-repo-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"client_reference_url": "https://cloud.google.com/nodejs/docs/reference/language/latest/",
"release_quality": "ga",
"samples": [
{
"id": "quickstart",
"name": "Quickstart",
"file": "quickstart.js",
"docs_link": "https://cloud.google.com/natural-language/docs/quickstart-client-libraries",
"usage": "node quickstart.js"
},
{
"id": "analyze-v1",
"name": "Analyze v1",
Expand All @@ -18,6 +25,27 @@
"file": "analyze.v1beta2.js",
"docs_link": "https://cloud.google.com/natural-language/docs/",
"usage": "node analyze.v1beta2.js --help"
},
{
"id": "automl-nl-dataset",
"name": "AutoML Dataset",
"file": "automl/automlNaturalLanguageDataset.js",
"docs_link": "https://cloud.google.com/natural-language/docs/",
"usage": "node automl/automlNaturalLanguageDataset.js --help"
},
{
"id": "automl-nl-model",
"name": "AutoML Model",
"file": "automl/automlNaturalLanguageModel.js",
"docs_link": "https://cloud.google.com/natural-language/docs/",
"usage": "node automl/automlNaturalLanguageModel.js --help"
},
{
"id": "automl-nl-predict",
"name": "AutoML Predict",
"file": "automl/automlNaturalLanguagePredict.js",
"docs_link": "https://cloud.google.com/natural-language/docs/",
"usage": "node automl/automlNaturalLanguagePredict.js --help"
}
]
}
1 change: 1 addition & 0 deletions .kokoro/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ cd $(dirname $0)/..

npm install
npm test
./node_modules/nyc/bin/nyc.js report

bash $KOKORO_GFILE_DIR/codecov.sh
3 changes: 2 additions & 1 deletion .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"exclude": [
"src/*{/*,/**/*}.js",
"src/*/v*/*.js",
"test/**/*.js"
"test/**/*.js",
"build/test"
],
"watermarks": {
"branches": [
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
117 changes: 53 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
[//]: # "To regenerate it, use `npm run generate-scaffolding`."
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>

# [Google Cloud Natural Language API: Node.js Client](https://github.com/googleapis/nodejs-language)
Expand All @@ -6,89 +8,58 @@
[![npm version](https://img.shields.io/npm/v/@google-cloud/language.svg)](https://www.npmjs.org/package/@google-cloud/language)
[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-language/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-language)

> Node.js idiomatic client for [Natural Language API][product-docs].
[Cloud Natural Language API](https://cloud.google.com/natural-language/docs) 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.


* [Natural Language API Node.js Client API Reference][client-docs]
* [github.com/googleapis/nodejs-language](https://github.com/googleapis/nodejs-language)
* [Natural Language API Documentation][product-docs]

Read more about the client libraries for Cloud APIs, including the older
Google APIs Client Libraries, in [Client Libraries Explained][explained].

[explained]: https://cloud.google.com/apis/docs/client-libraries-explained

**Table of contents:**

* [Quickstart](#quickstart)
* [Before you begin](#before-you-begin)
* [Installing the client library](#installing-the-client-library)
* [Using the client library](#using-the-client-library)
* [Using the client library](#using-the-client-library)
* [Samples](#samples)
* [Versioning](#versioning)
* [Contributing](#contributing)
* [License](#license)

## Quickstart
## Using the client library

### Before you begin
1. [Select or create a Cloud Platform project][projects].

1. Select or create a Cloud Platform project.
1. [Enable billing for your project][billing].

[Go to the projects page][projects]
1. [Enable the Google Cloud Natural Language API API][enable_api].

1. Enable billing for your project.
1. [Set up authentication with a service account][auth] so you can access the
API from your local workstation.

[Enable billing][billing]
1. Install the client library:

1. Enable the Google Cloud Natural Language API API.
npm install --save @google-cloud/language

[Enable the API][enable_api]
1. Try an example:

1. [Set up authentication with a service account][auth] so you can access the
API from your local workstation.
```javascript
async function main() {
// Imports the Google Cloud client library
const language = require('@google-cloud/language');

[projects]: https://console.cloud.google.com/project
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=language.googleapis.com
[auth]: https://cloud.google.com/docs/authentication/getting-started
// Instantiates a client
const client = new language.LanguageServiceClient();

### Installing the client library
// The text to analyze
const text = 'Hello, world!';

npm install --save @google-cloud/language
const document = {
content: text,
type: 'PLAIN_TEXT',
};

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

```javascript
// 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
client
.analyzeSentiment({document: document})
.then(results => {
const sentiment = results[0].documentSentiment;

console.log(`Text: ${text}`);
console.log(`Sentiment score: ${sentiment.score}`);
console.log(`Sentiment magnitude: ${sentiment.magnitude}`);
})
.catch(err => {
console.error('ERROR:', err);
});
console.log(`Text: ${text}`);
console.log(`Sentiment score: ${sentiment.score}`);
console.log(`Sentiment magnitude: ${sentiment.magnitude}`);
}

main().catch(console.error);
```

## Samples
Expand All @@ -98,8 +69,12 @@ has instructions for running the samples.

| Sample | Source Code | Try it |
| --------------------------- | --------------------------------- | ------ |
| Quickstart | [source code](https://github.com/googleapis/nodejs-language/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-language&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
| Analyze v1 | [source code](https://github.com/googleapis/nodejs-language/blob/master/samples/analyze.v1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-language&page=editor&open_in_editor=samples/analyze.v1.js,samples/README.md) |
| Analyze v1beta2 | [source code](https://github.com/googleapis/nodejs-language/blob/master/samples/analyze.v1beta2.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-language&page=editor&open_in_editor=samples/analyze.v1beta2.js,samples/README.md) |
| AutoML Dataset | [source code](https://github.com/googleapis/nodejs-language/blob/master/samples/automl/automlNaturalLanguageDataset.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-language&page=editor&open_in_editor=samples/automl/automlNaturalLanguageDataset.js,samples/README.md) |
| AutoML Model | [source code](https://github.com/googleapis/nodejs-language/blob/master/samples/automl/automlNaturalLanguageModel.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-language&page=editor&open_in_editor=samples/automl/automlNaturalLanguageModel.js,samples/README.md) |
| AutoML Predict | [source code](https://github.com/googleapis/nodejs-language/blob/master/samples/automl/automlNaturalLanguagePredict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-language&page=editor&open_in_editor=samples/automl/automlNaturalLanguagePredict.js,samples/README.md) |

The [Natural Language API Node.js Client API Reference][client-docs] documentation
also contains samples.
Expand Down Expand Up @@ -128,7 +103,21 @@ Apache Version 2.0

See [LICENSE](https://github.com/googleapis/nodejs-language/blob/master/LICENSE)

## What's Next

* [Natural Language API Documentation][product-docs]
* [Natural Language API Node.js Client API Reference][client-docs]
* [github.com/googleapis/nodejs-language](https://github.com/googleapis/nodejs-language)

Read more about the client libraries for Cloud APIs, including the older
Google APIs Client Libraries, in [Client Libraries Explained][explained].

[explained]: https://cloud.google.com/apis/docs/client-libraries-explained

[client-docs]: https://cloud.google.com/nodejs/docs/reference/language/latest/
[product-docs]: https://cloud.google.com/natural-language/docs
[shell_img]: //gstatic.com/cloudssh/images/open-btn.png

[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
[projects]: https://console.cloud.google.com/project
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=language.googleapis.com
[auth]: https://cloud.google.com/docs/authentication/getting-started
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@
"Google Cloud Natural Language API"
],
"scripts": {
"cover": "nyc --reporter=lcov mocha test/*.js && nyc report",
"docs": "jsdoc -c .jsdoc.js",
"generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json",
"lint": "eslint '**/*.js'",
"samples-test": "cd samples/ && npm test && cd ../",
"system-test": "mocha system-test/*.js --timeout 600000",
"test-no-cover": "mocha test/*.js",
"test": "npm run cover",
"test": "nyc mocha",
"fix": "eslint --fix '**/*.js'"
},
"dependencies": {
Expand Down
Loading

0 comments on commit c57b5df

Please sign in to comment.