@@ -18,6 +18,8 @@ var morphology = require("../lib/morphology");
1818var tokens = require ( "../lib/tokens" ) ;
1919var topics = require ( "../lib/topics" ) ;
2020var sentences = require ( "../lib/sentences" ) ;
21+ var similarTerms = require ( "../lib/similarTerms" ) ;
22+ var semanticVectors = require ( "../lib/semanticVectors" ) ;
2123var info = require ( "../lib/info" ) ;
2224var ping = require ( "../lib/ping" ) ;
2325var syntax_dependencies = require ( "../lib/syntax_dependencies" ) ;
@@ -686,12 +688,65 @@ describe("Sentences Endpoint", function() {
686688 } ) ;
687689} ) ;
688690
689- describe ( "Text Embedding Endpoint" , function ( ) {
691+ describe ( "Similar Terms Endpoint" , function ( ) {
690692 beforeEach ( function ( done ) {
691693 var mockResponse = JSON . stringify ( { 'name' : 'Rosette API' , 'versionChecked' : true } ) ;
692694
693695 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' )
695750 . query ( { "clientVersion" : "1.1" } )
696751 . reply ( 200 , JSON . parse ( mockResponse ) ) ;
697752 done ( ) ;
@@ -702,11 +757,11 @@ describe("Text Embedding Endpoint", function() {
702757 done ( ) ;
703758 } ) ;
704759
705- it ( "successfully calls the textEmbedding endpoint" , function ( done ) {
760+ it ( "successfully calls the semanticVectors endpoint" , function ( done ) {
706761 var api = new Api ( '123456789' , 'https://api.rosette.com/rest/v1' ) ;
707762 api . parameters . content = "Some Content" ;
708763
709- api . rosette ( "textEmbedding " , function ( err , res ) {
764+ api . rosette ( "semanticVectors " , function ( err , res ) {
710765 chai . expect ( err ) . to . be . null ;
711766 chai . expect ( res . name ) . to . equal ( 'Rosette API' ) ;
712767 done ( ) ;
@@ -719,7 +774,7 @@ describe("Text Embedding Endpoint", function() {
719774 api . parameters . content = "Sample Content" ;
720775 api . parameters . contentUri = "http://some.url.com" ;
721776
722- api . rosette ( "textEmbedding " , function ( err , res ) {
777+ api . rosette ( "semanticVectors " , function ( err , res ) {
723778 chai . expect ( err ) . to . not . be . null ;
724779 chai . expect ( err . name ) . to . equal ( 'RosetteException' ) ;
725780 chai . expect ( err . message ) . to . contain ( 'badArgument' ) ;
@@ -730,7 +785,7 @@ describe("Text Embedding Endpoint", function() {
730785 it ( "detects neither content nor contentUri are defined" , function ( done ) {
731786 var api = new Api ( '123456789' , 'https://api.rosette.com/rest/v1' ) ;
732787
733- api . rosette ( "textEmbedding " , function ( err , res ) {
788+ api . rosette ( "semanticVectors " , function ( err , res ) {
734789 chai . expect ( err ) . to . not . be . null ;
735790 chai . expect ( err . name ) . to . equal ( 'RosetteException' ) ;
736791 chai . expect ( err . message ) . to . contain ( 'badArgument' ) ;
0 commit comments