Skip to content

Commit

Permalink
Update Language samples. (#254)
Browse files Browse the repository at this point in the history
* Update Language samples.

* Address comments.
  • Loading branch information
jmdobry authored and sofisl committed Oct 13, 2022
1 parent 573632f commit e98b1d7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 76 deletions.
31 changes: 16 additions & 15 deletions packages/google-cloud-language/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,26 @@ __Usage:__ `node analyze --help`

```
Commands:
sentimentFromString <text> Detect the sentiment of a block of text.
sentimentFromFile <bucket> <filename> Detect the sentiment of text in a GCS file.
entitiesFromString <text> Detect the entities of a block of text.
entitiesFromFile <bucket> <filename> Detect the entities of text in a GCS file.
syntaxFromString <text> Detect the syntax of a block of text.
syntaxFromFile <bucket> <filename> Detect the syntax of text in a GCS file.
sentimentOfText <text> Detect the sentiment of a block of text.
sentimentInFile <bucket> <filename> Detect the sentiment of text in a GCS file.
entitiesOfText <text> Detect the entities of a block of text.
entitiesInFile <bucket> <filename> Detect the entities of text in a GCS file.
syntaxOfText <text> Detect the syntax of a block of text.
syntaxInFile <bucket> <filename> Detect the syntax of text in a GCS file.
Options:
--language, -l The language of the text. [string]
--type, -t Type of text [string] [choices: "text", "html"] [default: "text"]
--help Show help [boolean]
--help Show help [boolean]
Examples:
node analyze sentimentFromString "President Obama is speaking at the White House."
node analyze sentimentFromFile my-bucket file.txt
node analyze entitiesFromString "<p>President Obama is speaking at the White House.</p>" -t html
node analyze entitiesFromFile my-bucket file.txt
node analyze syntaxFromString "President Obama is speaking at the White House."
node analyze syntaxFromFile my-bucket es_file.txt -l es
node analyze sentimentOfText "President Obama is speaking at
the White House."
node analyze sentimentInFile my-bucket file.txt
node analyze entitiesOfText "President Obama is speaking at
the White House."
node analyze entitiesInFile my-bucket file.txt
node analyze syntaxOfText "President Obama is speaking at
the White House."
node analyze syntaxInFile my-bucket file.txt
For more information, see https://cloud.google.com/natural-language/docs
```
Expand Down
13 changes: 4 additions & 9 deletions packages/google-cloud-language/samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
"license": "Apache Version 2.0",
"author": "Google Inc.",
"scripts": {
"test": "mocha -R spec -t 120000 --require intelli-espower-loader ../test/_setup.js test/*.test.js",
"system-test": "mocha -R spec -t 120000 --require intelli-espower-loader ../system-test/_setup.js system-test/*.test.js"
"test": "cd ..; npm run st -- language/system-test/*"
},
"dependencies": {
"@google-cloud/language": "^0.1.2",
"@google-cloud/storage": "^0.1.1",
"yargs": "^5.0.0"
},
"devDependencies": {
"mocha": "^3.0.2",
"node-uuid": "^1.4.7"
"@google-cloud/language": "^0.6.0",
"@google-cloud/storage": "^0.4.0",
"yargs": "^6.4.0"
},
"engines": {
"node": ">=4.3.2"
Expand Down
14 changes: 6 additions & 8 deletions packages/google-cloud-language/samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ const languageClient = Language({
const text = 'Hello, world!';

// Detects the sentiment of the text
languageClient.detectSentiment(text, { verbose: true }, (err, sentiment) => {
if (err) {
console.error(err);
return;
}
languageClient.detectSentiment(text)
.then((results) => {
const sentiment = results[0];

console.log('Text: %s', text);
console.log('Sentiment: %j', sentiment);
});
console.log(`Text: ${text}`);
console.log(`Sentiment: ${sentiment}`);
});
// [END language_quickstart]
44 changes: 0 additions & 44 deletions packages/google-cloud-language/samples/test/quickstart.test.js

This file was deleted.

0 comments on commit e98b1d7

Please sign in to comment.