@@ -18,6 +18,8 @@ var morphology = require("../lib/morphology");
18
18
var tokens = require ( "../lib/tokens" ) ;
19
19
var topics = require ( "../lib/topics" ) ;
20
20
var sentences = require ( "../lib/sentences" ) ;
21
+ var similarTerms = require ( "../lib/similarTerms" ) ;
22
+ var semanticVectors = require ( "../lib/semanticVectors" ) ;
21
23
var info = require ( "../lib/info" ) ;
22
24
var ping = require ( "../lib/ping" ) ;
23
25
var syntax_dependencies = require ( "../lib/syntax_dependencies" ) ;
@@ -686,12 +688,65 @@ describe("Sentences Endpoint", function() {
686
688
} ) ;
687
689
} ) ;
688
690
689
- describe ( "Text Embedding Endpoint" , function ( ) {
691
+ describe ( "Similar Terms Endpoint" , function ( ) {
690
692
beforeEach ( function ( done ) {
691
693
var mockResponse = JSON . stringify ( { 'name' : 'Rosette API' , 'versionChecked' : true } ) ;
692
694
693
695
nock ( 'https://api.rosette.com' , { "encodedQueryParams" : true } )
694
- . post ( '/rest/v1/text-embedding' )
696
+ . post ( '/rest/v1/semantics/similar' )
697
+ . query ( { "clientVersion" : "1.1" } )
698
+ . reply ( 200 , JSON . parse ( mockResponse ) ) ;
699
+ done ( )
700
+ } ) ;
701
+
702
+ afterEach ( function ( done ) {
703
+ nock . cleanAll ( ) ;
704
+ done ( ) ;
705
+ } ) ;
706
+
707
+ it ( "successfully calls the similarTerms endpoint" , function ( done ) {
708
+ var api = new Api ( '123456789' , 'https://api.rosette.com/rest/v1' ) ;
709
+ api . parameters . content = "Some Content" ;
710
+
711
+ api . rosette ( "similarTerms" , function ( err , res ) {
712
+ chai . expect ( err ) . to . be . null ;
713
+ chai . expect ( res . name ) . to . equal ( 'Rosette API' ) ;
714
+ done ( ) ;
715
+ } ) ;
716
+
717
+ } ) ;
718
+
719
+ it ( "detects content and contentUri are defined" , function ( done ) {
720
+ var api = new Api ( '123456789' , 'https://api.rosette.com/rest/v1' ) ;
721
+ api . parameters . content = "Sample Content" ;
722
+ api . parameters . contentUri = "http://some.url.com" ;
723
+
724
+ api . rosette ( "similarTerms" , function ( err , res ) {
725
+ chai . expect ( err ) . to . not . be . null ;
726
+ chai . expect ( err . name ) . to . equal ( 'RosetteException' ) ;
727
+ chai . expect ( err . message ) . to . contain ( 'badArgument' ) ;
728
+ done ( ) ;
729
+ } ) ;
730
+ } ) ;
731
+
732
+ it ( "detects neither content nor contentUri are defined" , function ( done ) {
733
+ var api = new Api ( '123456789' , 'https://api.rosette.com/rest/v1' ) ;
734
+
735
+ api . rosette ( "similarTerms" , function ( err , res ) {
736
+ chai . expect ( err ) . to . not . be . null ;
737
+ chai . expect ( err . name ) . to . equal ( 'RosetteException' ) ;
738
+ chai . expect ( err . message ) . to . contain ( 'badArgument' ) ;
739
+ done ( ) ;
740
+ } ) ;
741
+ } ) ;
742
+ } ) ;
743
+
744
+ describe ( "Semantic Vectors Endpoint" , function ( ) {
745
+ beforeEach ( function ( done ) {
746
+ var mockResponse = JSON . stringify ( { 'name' : 'Rosette API' , 'versionChecked' : true } ) ;
747
+
748
+ nock ( 'https://api.rosette.com' , { "encodedQueryParams" : true } )
749
+ . post ( '/rest/v1/semantics/vector' )
695
750
. query ( { "clientVersion" : "1.1" } )
696
751
. reply ( 200 , JSON . parse ( mockResponse ) ) ;
697
752
done ( ) ;
@@ -702,11 +757,11 @@ describe("Text Embedding Endpoint", function() {
702
757
done ( ) ;
703
758
} ) ;
704
759
705
- it ( "successfully calls the textEmbedding endpoint" , function ( done ) {
760
+ it ( "successfully calls the semanticVectors endpoint" , function ( done ) {
706
761
var api = new Api ( '123456789' , 'https://api.rosette.com/rest/v1' ) ;
707
762
api . parameters . content = "Some Content" ;
708
763
709
- api . rosette ( "textEmbedding " , function ( err , res ) {
764
+ api . rosette ( "semanticVectors " , function ( err , res ) {
710
765
chai . expect ( err ) . to . be . null ;
711
766
chai . expect ( res . name ) . to . equal ( 'Rosette API' ) ;
712
767
done ( ) ;
@@ -719,7 +774,7 @@ describe("Text Embedding Endpoint", function() {
719
774
api . parameters . content = "Sample Content" ;
720
775
api . parameters . contentUri = "http://some.url.com" ;
721
776
722
- api . rosette ( "textEmbedding " , function ( err , res ) {
777
+ api . rosette ( "semanticVectors " , function ( err , res ) {
723
778
chai . expect ( err ) . to . not . be . null ;
724
779
chai . expect ( err . name ) . to . equal ( 'RosetteException' ) ;
725
780
chai . expect ( err . message ) . to . contain ( 'badArgument' ) ;
@@ -730,7 +785,7 @@ describe("Text Embedding Endpoint", function() {
730
785
it ( "detects neither content nor contentUri are defined" , function ( done ) {
731
786
var api = new Api ( '123456789' , 'https://api.rosette.com/rest/v1' ) ;
732
787
733
- api . rosette ( "textEmbedding " , function ( err , res ) {
788
+ api . rosette ( "semanticVectors " , function ( err , res ) {
734
789
chai . expect ( err ) . to . not . be . null ;
735
790
chai . expect ( err . name ) . to . equal ( 'RosetteException' ) ;
736
791
chai . expect ( err . message ) . to . contain ( 'badArgument' ) ;
0 commit comments