@@ -213,6 +213,55 @@ describe( 'Language model validity checks', function () {
213213 } ) ;
214214} ) ;
215215
216+ describe ( 'Annotation pipe validity checks' , function ( ) {
217+ it ( 'should throw error when incorrect pipe datatype is passed' , function ( ) {
218+ expect ( winkNLP . bind ( null , model , 3 ) ) . to . throw ( / ^ w i n k - n l p : i n v a l i d p i p e , i t m u s t b e a n a r r a y i n s t e a d f o u n d a " n u m b e r " ./ ) ;
219+ } ) ;
220+
221+ it ( 'should throw error when incorrect annotation type is passed' , function ( ) {
222+ expect ( winkNLP . bind ( null , model , [ 'wrong' ] ) ) . to . throw ( / ^ w i n k - n l p : i n v a l i d p i p e a n n o t a t i o n " w r o n g " f o u n d ./ ) ;
223+ } ) ;
224+ } ) ;
225+
226+ describe ( 'Empty Annotation pipe should not detect any of the existing annotations' , function ( ) {
227+ const nlpNoAnno = winkNLP ( model , [ ] ) ;
228+ it ( 'should still learn from patterns' , function ( ) {
229+ const patterns = [
230+ { name : 'adjectiveNounPair' , patterns : [ 'ADJ' ] }
231+ ] ;
232+ expect ( nlpNoAnno . learnCustomEntities ( patterns ) ) . to . equal ( 1 ) ;
233+ } ) ;
234+
235+ const doc = nlpNoAnno . readDoc ( 'Hello World! Not happy! :-)' ) ;
236+ it ( 'should return single sentence' , function ( ) {
237+ expect ( doc . sentences ( ) . length ( ) ) . to . equal ( 1 ) ;
238+ expect ( doc . sentences ( ) . out ( ) [ 0 ] ) . to . equal ( doc . out ( ) ) ;
239+ } ) ;
240+
241+ it ( 'should not return any negated token' , function ( ) {
242+ // "happy" would be negated otherwise!
243+ expect ( doc . tokens ( ) . itemAt ( 4 ) . out ( its . negationFlag ) ) . to . equal ( false ) ;
244+ } ) ;
245+
246+ it ( 'should return overall sentiment as "0"' , function ( ) {
247+ expect ( doc . out ( its . sentiment ) ) . to . equal ( 0 ) ;
248+ } ) ;
249+
250+ it ( 'should return all pos as "UNK"' , function ( ) {
251+ expect ( doc . tokens ( ) . out ( its . pos ) ) . to . deep . equal ( [ 'UNK' , 'UNK' , 'UNK' , 'UNK' , 'UNK' , 'UNK' , 'UNK' ] ) ;
252+ } ) ;
253+
254+ it ( 'should return empty entity array' , function ( ) {
255+ expect ( doc . entities ( ) . out ( ) ) . to . deep . equal ( [ ] ) ;
256+ expect ( doc . entities ( ) . length ( ) ) . to . deep . equal ( 0 ) ;
257+ } ) ;
258+
259+ it ( 'should return empty custom entity array' , function ( ) {
260+ expect ( doc . entities ( ) . out ( ) ) . to . deep . equal ( [ ] ) ;
261+ expect ( doc . entities ( ) . length ( ) ) . to . deep . equal ( 0 ) ;
262+ } ) ;
263+ } ) ;
264+
216265// describe( 'Limits handling', function () {
217266// it( 'should throw error', function () {
218267// expect( nlp.readDoc.bind( null, lslSentence ) ).to.throw( /^wink-nlp: memory/ );
0 commit comments