|
1 | | -<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"/> |
| 1 | +Most samples for the [Google Cloud Natural Language API Node.js Client][client] |
| 2 | +have moved to [github.com/googleapis/nodejs-language: samples/][samples]. |
2 | 3 |
|
3 | | -# Google Cloud Natural Language API Node.js Samples |
4 | | - |
5 | | -[]() |
6 | | - |
7 | | -[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. |
8 | | - |
9 | | -## Table of Contents |
10 | | - |
11 | | -* [Setup](#setup) |
12 | | -* [Samples](#samples) |
13 | | - * [Analyze v1](#analyze-v1) |
14 | | - * [Analyze v1beta2](#analyze-v1beta2) |
15 | | - * [Slack Bot](#slack-bot) |
16 | | -* [Running the tests](#running-the-tests) |
17 | | - |
18 | | -## Setup |
19 | | - |
20 | | -1. Read [Prerequisites][prereq] and [How to run a sample][run] first. |
21 | | -1. Install dependencies: |
22 | | - |
23 | | - With **npm**: |
24 | | - |
25 | | - npm install |
26 | | - |
27 | | - With **yarn**: |
28 | | - |
29 | | - yarn install |
30 | | - |
31 | | -[prereq]: ../README.md#prerequisites |
32 | | -[run]: ../README.md#how-to-run-a-sample |
33 | | - |
34 | | -## Samples |
35 | | - |
36 | | -### Analyze v1 |
37 | | - |
38 | | -View the [documentation][analyze-v1_0_docs] or the [source code][analyze-v1_0_code]. |
39 | | - |
40 | | -__Usage:__ `node analyze.v1.js --help` |
41 | | - |
42 | | -``` |
43 | | -Commands: |
44 | | - sentiment-text <text> Detects sentiment of a string. |
45 | | - sentiment-file <bucketName> <fileName> Detects sentiment in a file in Google Cloud Storage. |
46 | | - entities-text <text> Detects entities in a string. |
47 | | - entities-file <bucketName> <fileName> Detects entities in a file in Google Cloud Storage. |
48 | | - syntax-text <text> Detects syntax of a string. |
49 | | - syntax-file <bucketName> <fileName> Detects syntax in a file in Google Cloud Storage. |
50 | | - entity-sentiment-text <text> Detects sentiment of the entities in a string. |
51 | | - entity-sentiment-file <bucketName> <fileName> Detects sentiment of the entities in a file in Google Cloud Storage. |
52 | | -
|
53 | | -Options: |
54 | | - --help Show help [boolean] |
55 | | -
|
56 | | -Examples: |
57 | | - node analyze.v1.js sentiment-text "President Obama is speaking at the White House." |
58 | | - node analyze.v1.js sentiment-file my-bucket file.txt Detects sentiment in gs://my-bucket/file.txt |
59 | | - node analyze.v1.js entities-text "President Obama is speaking at the White House." |
60 | | - node analyze.v1.js entities-file my-bucket file.txt Detects entities in gs://my-bucket/file.txt |
61 | | - node analyze.v1.js syntax-text "President Obama is speaking at the White House." |
62 | | - node analyze.v1.js syntax-file my-bucket file.txt Detects syntax in gs://my-bucket/file.txt |
63 | | - node analyze.v1.js entity-sentiment-text "President Obama is speaking at the White House." |
64 | | - node analyze.v1.js entity-sentiment-file my-bucket file.txt Detects sentiment of entities in gs://my-bucket/file.txt |
65 | | -
|
66 | | -For more information, see https://cloud.google.com/natural-language/docs |
67 | | -``` |
68 | | - |
69 | | -[analyze-v1_0_docs]: https://cloud.google.com/natural-language/docs/ |
70 | | -[analyze-v1_0_code]: analyze.v1.js |
71 | | - |
72 | | -### Analyze v1beta2 |
73 | | - |
74 | | -View the [documentation][analyze-v1beta2_1_docs] or the [source code][analyze-v1beta2_1_code]. |
75 | | - |
76 | | -__Usage:__ `node analyze.v1beta2.js --help` |
77 | | - |
78 | | -``` |
79 | | -Commands: |
80 | | - sentiment-text <text> Detects sentiment of a string. |
81 | | - sentiment-file <bucketName> <fileName> Detects sentiment in a file in Google Cloud Storage. |
82 | | - entities-text <text> Detects entities in a string. |
83 | | - entities-file <bucketName> <fileName> Detects entities in a file in Google Cloud Storage. |
84 | | - syntax-text <text> Detects syntax of a string. |
85 | | - syntax-file <bucketName> <fileName> Detects syntax in a file in Google Cloud Storage. |
86 | | - classify-text <text> Classifies text of a string. |
87 | | - classify-file <bucketName> <fileName> Classifies text in a file in Google Cloud Storage. |
88 | | -
|
89 | | -Options: |
90 | | - --help Show help [boolean] |
91 | | -
|
92 | | -Examples: |
93 | | - node analyze.v1beta2.js sentiment-text "President Obama is speaking at the White House." |
94 | | - node analyze.v1beta2.js sentiment-file my-bucket file.txt Detects sentiment in gs://my-bucket/file.txt |
95 | | - node analyze.v1beta2.js entities-text "President Obama is speaking at the White House." |
96 | | - node analyze.v1beta2.js entities-file my-bucket file.txt Detects entities in gs://my-bucket/file.txt |
97 | | - node analyze.v1beta2.js syntax-text "President Obama is speaking at the White House." |
98 | | - node analyze.v1beta2.js syntax-file my-bucket file.txt Detects syntax in gs://my-bucket/file.txt |
99 | | - node analyze.v1beta2.js classify-text "Currently the API requires 20 tokens in order \ |
100 | | - to return non-empty results. Let's use a longer piece of text for the sample in order to win." |
101 | | - node analyze.v1beta2.js classify-file my-bucket Detects syntax in gs://my-bucket/android_text.txt |
102 | | - android_text.txt |
103 | | -
|
104 | | -For more information, see https://cloud.google.com/natural-language/docs |
105 | | -``` |
106 | | - |
107 | | -[analyze-v1beta2_1_docs]: https://cloud.google.com/natural-language/docs/ |
108 | | -[analyze-v1beta2_1_code]: analyze.v1beta2.js |
109 | | - |
110 | | -### Slack Bot |
| 4 | +[client]: https://github.com/googleapis/nodejs-language |
| 5 | +[samples]: https://github.com/googleapis/nodejs-language/tree/master/samples |
111 | 6 |
|
| 7 | +### Slack Bot sample |
112 | 8 |
|
113 | 9 | View the [README](slackbot/README.md). |
114 | | - |
115 | | - |
116 | | - |
117 | | -## Running the tests |
118 | | - |
119 | | -1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables. |
120 | | - |
121 | | -1. Run the tests: |
122 | | - |
123 | | - With **npm**: |
124 | | - |
125 | | - npm test |
126 | | - |
127 | | - With **yarn**: |
128 | | - |
129 | | - yarn test |
0 commit comments