Skip to content

Commit 966f443

Browse files
test(wink-nlp-specs): add tests for annotations pipe config
1 parent 9b8aae7 commit 966f443

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/wink-nlp-specs.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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( /^wink-nlp: invalid pipe, it must be an array instead found a "number"./ );
219+
} );
220+
221+
it( 'should throw error when incorrect annotation type is passed', function () {
222+
expect( winkNLP.bind( null, model, [ 'wrong' ] ) ).to.throw( /^wink-nlp: invalid pipe annotation "wrong" found./ );
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

Comments
 (0)