@@ -34,7 +34,7 @@ describe('Language', function() {
34
34
var BUCKET ;
35
35
36
36
var TEXT_CONTENT_SENTENCES = [
37
- 'Hello from stephen and dave !' ,
37
+ 'Hello from stephen and david !' ,
38
38
'If you find yourself in michigan, come say hi!'
39
39
] ;
40
40
@@ -313,150 +313,182 @@ describe('Language', function() {
313
313
314
314
function validateAnnotationSimple ( callback ) {
315
315
return function ( err , annotation , apiResponse ) {
316
- assert . ifError ( err ) ;
316
+ try {
317
+ assert . ifError ( err ) ;
317
318
318
- assert . strictEqual ( annotation . language , 'en' ) ;
319
+ assert . strictEqual ( annotation . language , 'en' ) ;
319
320
320
- assert ( is . number ( annotation . sentiment ) ) ;
321
+ assert ( is . number ( annotation . sentiment ) ) ;
321
322
322
- assert . deepEqual ( annotation . entities , {
323
- people : [ 'stephen' , 'dave ' ] ,
324
- places : [ 'michigan' ]
325
- } ) ;
323
+ assert . deepEqual ( annotation . entities , {
324
+ people : [ 'stephen' , 'david ' ] ,
325
+ places : [ 'michigan' ]
326
+ } ) ;
326
327
327
- assert . deepEqual ( annotation . sentences , TEXT_CONTENT_SENTENCES ) ;
328
+ assert . deepEqual ( annotation . sentences , TEXT_CONTENT_SENTENCES ) ;
328
329
329
- assert ( is . array ( annotation . tokens ) ) ;
330
- assert . deepEqual ( annotation . tokens [ 0 ] , {
331
- text : 'Hello' ,
332
- partOfSpeech : 'Other: foreign words, typos, abbreviations' ,
333
- partOfSpeechTag : 'X'
334
- } ) ;
330
+ assert ( is . array ( annotation . tokens ) ) ;
331
+ assert . deepEqual ( annotation . tokens [ 0 ] , {
332
+ text : 'Hello' ,
333
+ partOfSpeech : 'Other: foreign words, typos, abbreviations' ,
334
+ partOfSpeechTag : 'X'
335
+ } ) ;
335
336
336
- assert ( is . object ( apiResponse ) ) ;
337
+ assert ( is . object ( apiResponse ) ) ;
337
338
338
- callback ( ) ;
339
+ callback ( ) ;
340
+ } catch ( e ) {
341
+ callback ( e ) ;
342
+ }
339
343
} ;
340
344
}
341
345
342
346
function validateAnnotationVerbose ( callback ) {
343
347
return function ( err , annotation , apiResponse ) {
344
- assert . ifError ( err ) ;
348
+ try {
349
+ assert . ifError ( err ) ;
345
350
346
- assert . strictEqual ( annotation . language , 'en' ) ;
351
+ assert . strictEqual ( annotation . language , 'en' ) ;
347
352
348
- assert ( is . object ( annotation . sentiment ) ) ;
353
+ assert ( is . object ( annotation . sentiment ) ) ;
349
354
350
- assert ( is . array ( annotation . entities . people ) ) ;
351
- assert . strictEqual ( annotation . entities . people . length , 2 ) ;
352
- assert ( is . object ( annotation . entities . people [ 0 ] ) ) ;
355
+ assert ( is . array ( annotation . entities . people ) ) ;
356
+ assert . strictEqual ( annotation . entities . people . length , 2 ) ;
357
+ assert ( is . object ( annotation . entities . people [ 0 ] ) ) ;
353
358
354
- assert ( is . array ( annotation . sentences ) ) ;
355
- assert ( is . object ( annotation . sentences [ 0 ] ) ) ;
359
+ assert ( is . array ( annotation . sentences ) ) ;
360
+ assert ( is . object ( annotation . sentences [ 0 ] ) ) ;
356
361
357
- assert ( is . array ( annotation . tokens ) ) ;
358
- assert ( is . object ( annotation . tokens [ 0 ] ) ) ;
359
- assert . strictEqual ( annotation . tokens [ 0 ] . text . content , 'Hello' ) ;
362
+ assert ( is . array ( annotation . tokens ) ) ;
363
+ assert ( is . object ( annotation . tokens [ 0 ] ) ) ;
364
+ assert . strictEqual ( annotation . tokens [ 0 ] . text . content , 'Hello' ) ;
360
365
361
- assert ( is . object ( apiResponse ) ) ;
366
+ assert ( is . object ( apiResponse ) ) ;
362
367
363
- callback ( ) ;
368
+ callback ( ) ;
369
+ } catch ( e ) {
370
+ callback ( e ) ;
371
+ }
364
372
} ;
365
373
}
366
374
367
375
function validateAnnotationSingleFeatureSimple ( callback ) {
368
376
return function ( err , annotation , apiResponse ) {
369
- assert . ifError ( err ) ;
377
+ try {
378
+ assert . ifError ( err ) ;
370
379
371
- assert . strictEqual ( annotation . language , 'en' ) ;
380
+ assert . strictEqual ( annotation . language , 'en' ) ;
372
381
373
- assert . deepEqual ( annotation . entities , {
374
- people : [ 'stephen' , 'dave ' ] ,
375
- places : [ 'michigan' ]
376
- } ) ;
382
+ assert . deepEqual ( annotation . entities , {
383
+ people : [ 'stephen' , 'david ' ] ,
384
+ places : [ 'michigan' ]
385
+ } ) ;
377
386
378
- assert . strictEqual ( annotation . sentences , undefined ) ;
379
- assert . strictEqual ( annotation . sentiment , undefined ) ;
380
- assert . strictEqual ( annotation . tokens , undefined ) ;
387
+ assert . strictEqual ( annotation . sentences , undefined ) ;
388
+ assert . strictEqual ( annotation . sentiment , undefined ) ;
389
+ assert . strictEqual ( annotation . tokens , undefined ) ;
381
390
382
- assert ( is . object ( apiResponse ) ) ;
391
+ assert ( is . object ( apiResponse ) ) ;
383
392
384
- callback ( ) ;
393
+ callback ( ) ;
394
+ } catch ( e ) {
395
+ callback ( e ) ;
396
+ }
385
397
} ;
386
398
}
387
399
388
400
function validateAnnotationSingleFeatureVerbose ( callback ) {
389
401
return function ( err , annotation , apiResponse ) {
390
- assert . ifError ( err ) ;
402
+ try {
403
+ assert . ifError ( err ) ;
391
404
392
- assert . strictEqual ( annotation . language , 'en' ) ;
405
+ assert . strictEqual ( annotation . language , 'en' ) ;
393
406
394
- assert ( is . array ( annotation . entities . people ) ) ;
395
- assert . strictEqual ( annotation . entities . people . length , 2 ) ;
396
- assert ( is . object ( annotation . entities . people [ 0 ] ) ) ;
407
+ assert ( is . array ( annotation . entities . people ) ) ;
408
+ assert . strictEqual ( annotation . entities . people . length , 2 ) ;
409
+ assert ( is . object ( annotation . entities . people [ 0 ] ) ) ;
397
410
398
- assert . strictEqual ( annotation . sentences , undefined ) ;
399
- assert . strictEqual ( annotation . sentiment , undefined ) ;
400
- assert . strictEqual ( annotation . tokens , undefined ) ;
411
+ assert . strictEqual ( annotation . sentences , undefined ) ;
412
+ assert . strictEqual ( annotation . sentiment , undefined ) ;
413
+ assert . strictEqual ( annotation . tokens , undefined ) ;
401
414
402
- assert ( is . object ( apiResponse ) ) ;
415
+ assert ( is . object ( apiResponse ) ) ;
403
416
404
- callback ( ) ;
417
+ callback ( ) ;
418
+ } catch ( e ) {
419
+ callback ( e ) ;
420
+ }
405
421
} ;
406
422
}
407
423
408
424
function validateEntitiesSimple ( callback ) {
409
425
return function ( err , entities , apiResponse ) {
410
- assert . ifError ( err ) ;
426
+ try {
427
+ assert . ifError ( err ) ;
411
428
412
- assert . deepEqual ( entities , {
413
- people : [ 'stephen' , 'dave ' ] ,
414
- places : [ 'michigan' ]
415
- } ) ;
429
+ assert . deepEqual ( entities , {
430
+ people : [ 'stephen' , 'david ' ] ,
431
+ places : [ 'michigan' ]
432
+ } ) ;
416
433
417
- assert ( is . object ( apiResponse ) ) ;
434
+ assert ( is . object ( apiResponse ) ) ;
418
435
419
- callback ( ) ;
436
+ callback ( ) ;
437
+ } catch ( e ) {
438
+ callback ( e ) ;
439
+ }
420
440
} ;
421
441
}
422
442
423
443
function validateEntitiesVerbose ( callback ) {
424
444
return function ( err , entities , apiResponse ) {
425
- assert . ifError ( err ) ;
445
+ try {
446
+ assert . ifError ( err ) ;
426
447
427
- assert ( is . array ( entities . people ) ) ;
428
- assert . strictEqual ( entities . people . length , 2 ) ;
429
- assert ( is . object ( entities . people [ 0 ] ) ) ;
448
+ assert ( is . array ( entities . people ) ) ;
449
+ assert . strictEqual ( entities . people . length , 2 ) ;
450
+ assert ( is . object ( entities . people [ 0 ] ) ) ;
430
451
431
- assert ( is . object ( apiResponse ) ) ;
452
+ assert ( is . object ( apiResponse ) ) ;
432
453
433
- callback ( ) ;
454
+ callback ( ) ;
455
+ } catch ( e ) {
456
+ callback ( e ) ;
457
+ }
434
458
} ;
435
459
}
436
460
437
461
function validateSentimentSimple ( callback ) {
438
462
return function ( err , sentiment , apiResponse ) {
439
- assert . ifError ( err ) ;
463
+ try {
464
+ assert . ifError ( err ) ;
440
465
441
- assert ( is . number ( sentiment ) ) ;
466
+ assert ( is . number ( sentiment ) ) ;
442
467
443
- assert ( is . object ( apiResponse ) ) ;
468
+ assert ( is . object ( apiResponse ) ) ;
444
469
445
- callback ( ) ;
470
+ callback ( ) ;
471
+ } catch ( e ) {
472
+ callback ( e ) ;
473
+ }
446
474
} ;
447
475
}
448
476
449
477
function validateSentimentVerbose ( callback ) {
450
478
return function ( err , sentiment , apiResponse ) {
451
- assert . ifError ( err ) ;
479
+ try {
480
+ assert . ifError ( err ) ;
452
481
453
- assert ( is . object ( sentiment ) ) ;
454
- assert ( is . number ( sentiment . polarity ) ) ;
455
- assert ( is . number ( sentiment . magnitude ) ) ;
482
+ assert ( is . object ( sentiment ) ) ;
483
+ assert ( is . number ( sentiment . polarity ) ) ;
484
+ assert ( is . number ( sentiment . magnitude ) ) ;
456
485
457
- assert ( is . object ( apiResponse ) ) ;
486
+ assert ( is . object ( apiResponse ) ) ;
458
487
459
- callback ( ) ;
488
+ callback ( ) ;
489
+ } catch ( e ) {
490
+ callback ( e ) ;
491
+ }
460
492
} ;
461
493
}
462
494
} ) ;
0 commit comments