From 2fef1018bc80514f2ad2cadd1ec943436c34b7ff Mon Sep 17 00:00:00 2001 From: Gus Class Date: Fri, 28 Jul 2017 15:34:50 -0700 Subject: [PATCH] Upgrades language samples to semi-gapic client (#435) * Upgrades language samples to semi-gapic client * Adds package lock, may fix flaky test. * Address comments * Fix lint --- .../google-cloud-language/samples/package.json | 2 +- .../google-cloud-language/samples/quickstart.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/google-cloud-language/samples/package.json b/packages/google-cloud-language/samples/package.json index c1a59c26e80..e8b7e28fd4d 100644 --- a/packages/google-cloud-language/samples/package.json +++ b/packages/google-cloud-language/samples/package.json @@ -23,7 +23,7 @@ "test": "npm run system-test" }, "dependencies": { - "@google-cloud/language": "0.10.5", + "@google-cloud/language": "0.11.0", "@google-cloud/storage": "1.1.1", "yargs": "8.0.2" }, diff --git a/packages/google-cloud-language/samples/quickstart.js b/packages/google-cloud-language/samples/quickstart.js index cadb7c4d3db..afc74fe253b 100644 --- a/packages/google-cloud-language/samples/quickstart.js +++ b/packages/google-cloud-language/samples/quickstart.js @@ -19,21 +19,21 @@ // Imports the Google Cloud client library const Language = require('@google-cloud/language'); -// Your Google Cloud Platform project ID -const projectId = 'YOUR_PROJECT_ID'; - // Instantiates a client -const language = Language({ - projectId: projectId -}); +const language = Language(); // The text to analyze const text = 'Hello, world!'; +const document = { + 'content': text, + type: 'PLAIN_TEXT' +}; + // Detects the sentiment of the text -language.detectSentiment(text) +language.analyzeSentiment({'document': document}) .then((results) => { - const sentiment = results[0]; + const sentiment = results[0].documentSentiment; console.log(`Text: ${text}`); console.log(`Sentiment score: ${sentiment.score}`);