@@ -29,17 +29,17 @@ var language = Language();
2929var storage = Storage ( ) ;
3030// [END setup]
3131
32- // [START analyze_sentiment ]
32+ // [START analyze_sentiment_from_string ]
3333/**
3434 * Detect the sentiment of a block of text.
3535 *
3636 * @param {string } text The text to analyze.
3737 * @param {object } [options] Configuration options.
38- * @param {string } [options.type] "text" or "html".
38+ * @param {string } [options.type] The type of the text, either "text" or "html".
3939 * @param {string } [options.language] The language of the text, e.g. "en".
4040 * @param {function } callback The callback function.
4141 */
42- function analyzeSentiment ( text , options , callback ) {
42+ function analyzeSentimentFromString ( text , options , callback ) {
4343 var document = language . document ( {
4444 content : text ,
4545 type : options . type ,
@@ -61,7 +61,7 @@ function analyzeSentiment (text, options, callback) {
6161 return callback ( null , sentiment ) ;
6262 } ) ;
6363}
64- // [END analyze_sentiment ]
64+ // [END analyze_sentiment_from_string ]
6565
6666// [START analyze_sentiment_from_file]
6767/**
@@ -71,7 +71,7 @@ function analyzeSentiment (text, options, callback) {
7171 * @param {string } filename The name of the file to be analyzed.
7272 * @param {object } [options] Optional configuration.
7373 * @param {string } [options.language] The language of the text, e.g. "en".
74- * @param {string } [options.type] "text" or "html".
74+ * @param {string } [options.type] The type of the text, either "text" or "html".
7575 * @param {function } callback The callback function.
7676 */
7777function analyzeSentimentFromFile ( bucket , filename , options , callback ) {
@@ -98,17 +98,17 @@ function analyzeSentimentFromFile (bucket, filename, options, callback) {
9898}
9999// [END analyze_sentiment_from_file]
100100
101- // [START analyze_entities ]
101+ // [START analyze_entities_from_string ]
102102/**
103103 * Detect the entities from a block of text.
104104 *
105105 * @param {string } text The text to analyze.
106106 * @param {object } [options] Optional configuration.
107107 * @param {string } [options.language] The language of the text, e.g. "en".
108- * @param {string } [options.type] "text" or "html".
108+ * @param {string } [options.type] The type of the text, either "text" or "html".
109109 * @param {function } callback The callback function.
110110 */
111- function analyzeEntities ( text , options , callback ) {
111+ function analyzeEntitiesFromString ( text , options , callback ) {
112112 var document = language . document ( {
113113 content : text ,
114114 type : options . type ,
@@ -130,7 +130,7 @@ function analyzeEntities (text, options, callback) {
130130 return callback ( null , entities ) ;
131131 } ) ;
132132}
133- // [END analyze_entities ]
133+ // [END analyze_entities_from_string ]
134134
135135// [START analyze_entities_from_file]
136136/**
@@ -140,7 +140,7 @@ function analyzeEntities (text, options, callback) {
140140 * @param {string } filename The name of the file to be analyzed.
141141 * @param {object } [options] Optional configuration.
142142 * @param {string } [options.language] The language of the text, e.g. "en".
143- * @param {string } [options.type] "text" or "html".
143+ * @param {string } [options.type] The type of the text, either "text" or "html".
144144 * @param {function } callback The callback function.
145145 */
146146function analyzeEntitiesFromFile ( bucket , filename , options , callback ) {
@@ -167,17 +167,17 @@ function analyzeEntitiesFromFile (bucket, filename, options, callback) {
167167}
168168// [END analyze_entities_from_file]
169169
170- // [START analyze_syntax ]
170+ // [START analyze_syntax_from_string ]
171171/**
172172 * Detect the syntax in a block of text.
173173 *
174174 * @param {string } text The text to analyze.
175175 * @param {object } [options] Optional configuration.
176176 * @param {string } [options.language] The language of the text, e.g. "en".
177- * @param {string } [options.type] "text" or "html".
177+ * @param {string } [options.type] The type of the text, either "text" or "html".
178178 * @param {function } callback The callback function.
179179 */
180- function analyzeSyntax ( text , options , callback ) {
180+ function analyzeSyntaxFromString ( text , options , callback ) {
181181 var document = language . document ( {
182182 content : text ,
183183 type : options . type ,
@@ -198,7 +198,7 @@ function analyzeSyntax (text, options, callback) {
198198 return callback ( null , apiResponse ) ;
199199 } ) ;
200200}
201- // [END analyze_syntax ]
201+ // [END analyze_syntax_from_string ]
202202
203203// [START analyze_syntax_from_file]
204204/**
@@ -208,7 +208,7 @@ function analyzeSyntax (text, options, callback) {
208208 * @param {string } filename The name of the file to be analyzed.
209209 * @param {object } [options] Optional configuration.
210210 * @param {string } [options.language] The language of the text, e.g. "en".
211- * @param {string } [options.type] "text" or "html".
211+ * @param {string } [options.type] The type of the text, either "text" or "html".
212212 * @param {function } callback The callback function.
213213 */
214214function analyzeSyntaxFromFile ( bucket , filename , options , callback ) {
@@ -240,11 +240,11 @@ var cli = require('yargs');
240240var utils = require ( '../utils' ) ;
241241
242242var program = module . exports = {
243- analyzeSentiment : analyzeSentiment ,
243+ analyzeSentimentFromString : analyzeSentimentFromString ,
244244 analyzeSentimentFromFile : analyzeSentimentFromFile ,
245- analyzeEntities : analyzeEntities ,
245+ analyzeEntitiesFromString : analyzeEntitiesFromString ,
246246 analyzeEntitiesFromFile : analyzeEntitiesFromFile ,
247- analyzeSyntax : analyzeSyntax ,
247+ analyzeSyntaxFromString : analyzeSyntaxFromString ,
248248 analyzeSyntaxFromFile : analyzeSyntaxFromFile ,
249249 main : function ( args ) {
250250 // Run the command-line program
@@ -254,22 +254,22 @@ var program = module.exports = {
254254
255255cli
256256 . demand ( 1 )
257- . command ( 'sentiment <text>' , 'Detect the sentiment of a block of text.' , { } , function ( options ) {
258- program . analyzeSentiment ( options . text , utils . pick ( options , [ 'language' , 'type' ] ) , utils . makeHandler ( ) ) ;
257+ . command ( 'sentimentFromString <text>' , 'Detect the sentiment of a block of text.' , { } , function ( options ) {
258+ program . analyzeSentimentFromString ( options . text , utils . pick ( options , [ 'language' , 'type' ] ) , utils . makeHandler ( ) ) ;
259259 } )
260260 . command ( 'sentimentFromFile <bucket> <filename>' , 'Detect the sentiment of text in a GCS file.' , { } , function ( options ) {
261261 program . analyzeSentimentFromFile ( options . bucket , options . filename , utils . pick ( options , [ 'language' , 'type' ] ) , utils . makeHandler ( ) ) ;
262262 } )
263- . command ( 'entities <text>' , 'Detect the entities of a block of text.' , { } , function ( options ) {
264- program . analyzeEntities ( options . text , utils . pick ( options , [ 'language' , 'type' ] ) , utils . makeHandler ( ) ) ;
263+ . command ( 'entitiesFromString <text>' , 'Detect the entities of a block of text.' , { } , function ( options ) {
264+ program . analyzeEntitiesFromString ( options . text , utils . pick ( options , [ 'language' , 'type' ] ) , utils . makeHandler ( ) ) ;
265265 } )
266266 . command ( 'entitiesFromFile <bucket> <filename>' , 'Detect the entities of text in a GCS file.' , { } , function ( options ) {
267267 program . analyzeEntitiesFromFile ( options . bucket , options . filename , utils . pick ( options , [ 'language' , 'type' ] ) , utils . makeHandler ( ) ) ;
268268 } )
269- . command ( 'syntax <text>' , 'Detect the syntax of a block of text.' , { } , function ( options ) {
270- program . analyzeSyntax ( options . text , utils . pick ( options , [ 'language' , 'type' ] ) , utils . makeHandler ( ) ) ;
269+ . command ( 'syntaxFromString <text>' , 'Detect the syntax of a block of text.' , { } , function ( options ) {
270+ program . analyzeSyntaxFromString ( options . text , utils . pick ( options , [ 'language' , 'type' ] ) , utils . makeHandler ( ) ) ;
271271 } )
272- . command ( 'syntaxFromFile <bucket> <filename>' , 'Detect the syntax of a block of text .' , { } , function ( options ) {
272+ . command ( 'syntaxFromFile <bucket> <filename>' , 'Detect the syntax of text in a GCS file .' , { } , function ( options ) {
273273 program . analyzeSyntaxFromFile ( options . bucket , options . filename , utils . pick ( options , [ 'language' , 'type' ] ) , utils . makeHandler ( ) ) ;
274274 } )
275275 . options ( {
@@ -290,13 +290,13 @@ cli
290290 global : true
291291 }
292292 } )
293- . example ( 'node $0 sentiment "President Obama is speaking at the White House."' , '' )
293+ . example ( 'node $0 sentimentFromString "President Obama is speaking at the White House."' , '' )
294294 . example ( 'node $0 sentimentFromFile my-bucket file.txt' , '' )
295- . example ( 'node $0 entities "<p>President Obama is speaking at the White House.</p> -t html" ' , '' )
295+ . example ( 'node $0 entitiesFromString "<p>President Obama is speaking at the White House.</p>" -t html' , '' )
296296 . example ( 'node $0 entitiesFromFile my-bucket file.txt' , '' )
297- . example ( 'node $0 syntax "President Obama is speaking at the White House."' , '' )
297+ . example ( 'node $0 syntaxFromString "President Obama is speaking at the White House."' , '' )
298298 . example ( 'node $0 syntaxFromFile my-bucket es_file.txt -l es' , '' )
299- . wrap ( 200 )
299+ . wrap ( 100 )
300300 . recommendCommands ( )
301301 . epilogue ( 'For more information, see https://cloud.google.com/natural-language/docs' ) ;
302302
0 commit comments