Skip to content

Commit 7100382

Browse files
test(wink-nlp-specs): ensure printed data is also tested
1 parent cdfbcdb commit 7100382

File tree

1 file changed

+247
-0
lines changed

1 file changed

+247
-0
lines changed

test/wink-nlp-specs.js

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,254 @@ describe( 'wink-nlp test-coverage and basic behavior', function () {
147147
} );
148148

149149
it( 'should display the correct tokens & their properties', function () {
150+
const tokens = [
151+
'🎭',
152+
'Mr.',
153+
'-',
154+
':)',
155+
'🎉',
156+
'🎉',
157+
'\n',
158+
159+
'(',
160+
'I.I.T.',
161+
')',
162+
'I.I.T',
163+
'\'s',
164+
'*',
165+
'good',
166+
'.',
167+
'*',
168+
'https://winkjs.org',
169+
'#great',
170+
'I',
171+
'met',
172+
'her',
173+
'in',
174+
'(',
175+
'*',
176+
'-',
177+
'\'80s',
178+
'-',
179+
'*',
180+
')',
181+
'\'',
182+
'and',
183+
'/',
184+
'or',
185+
')',
186+
'-',
187+
'\'',
188+
'cause',
189+
'\'',
190+
'Pappu',
191+
'pass',
192+
'ho',
193+
'gaya',
194+
'—',
195+
'HaHaHa',
196+
'.',
197+
'Recognise',
198+
'it',
199+
'Pappu',
200+
'(',
201+
'pappu',
202+
'recognise',
203+
')',
204+
'?',
205+
'I',
206+
'ca',
207+
'n\'t',
208+
'do',
209+
'!',
210+
'i',
211+
'\'ll',
212+
'\'ve',
213+
'to',
214+
'do',
215+
'!',
216+
'Strange',
217+
'!',
218+
'I.',
219+
'K.',
220+
'Gujral',
221+
'who',
222+
'am',
223+
'I',
224+
'?',
225+
'🎭',
226+
',',
227+
'[',
228+
'🧞',
229+
'[',
230+
'Dabbu',
231+
'(',
232+
'left',
233+
')',
234+
'(',
235+
'OOV',
236+
')',
237+
'March',
238+
'12',
239+
',',
240+
'1998',
241+
'e-mail',
242+
'server-less',
243+
'F-16',
244+
'zxcvbn',
245+
'-',
246+
'asfgh',
247+
'S.K.',
248+
'Saxena',
249+
'.',
250+
'Server-less',
251+
'computing',
252+
'is',
253+
'awesome',
254+
'.',
255+
'Mr.',
256+
'S.K.',
257+
'Saxena',
258+
'aaa',
259+
'.',
260+
'-',
261+
'bbb',
262+
'138375720109463900845220131105025504431',
263+
'resources094639008452'
264+
];
265+
266+
const prefixes = [
267+
'🎭', 'Mr', '-', ':)', '🎉', '🎉', '\n', 'pa', '(', 'I.', ')',
268+
'I.', '\'s', '*', 'go', '.', '*', 'ht', '#g', 'I', 'me', 'he',
269+
'in', '(', '*', '-', '\'8', '-', '*', ')', '\'', 'an', '/',
270+
'or', ')', '-', '\'', 'ca', '\'', 'Pa', 'pa', 'ho', 'ga', '—',
271+
'Ha', '.', 'Re', 'it', 'Pa', '(', 'pa', 're', ')', '?', 'I',
272+
'ca', 'n\'', 'do', '!', 'i', '\'l', '\'v', 'to', 'do', '!', 'St',
273+
'!', 'I.', 'K.', 'Gu', 'wh', 'am', 'I', '?', '🎭', ',', '[',
274+
'🧞', '[', 'Da', '(', 'le', ')', '(', 'OO', ')', 'Ma', '12',
275+
',', '19', 'e-', 'se', 'F-', 'zx', '-', 'as', 'S.', 'Sa', '.',
276+
'Se', 'co', 'is', 'aw', '.', 'Mr', 'S.', 'Sa', 'aa', '.', '-',
277+
'bb', '13', 're'
278+
];
279+
280+
const suffixes = [
281+
'🎭', 'Mr.', '-', ':)', '🎉', '🎉', '\n', 'com', '(', '.T.',
282+
')', 'I.T', '\'s', '*', 'ood', '.', '*', 'org', 'eat', 'I',
283+
'met', 'her', 'in', '(', '*', '-', '80s', '-', '*', ')',
284+
'\'', 'and', '/', 'or', ')', '-', '\'', 'use', '\'', 'ppu',
285+
'ass', 'ho', 'aya', '—', 'aHa', '.', 'ise', 'it', 'ppu', '(',
286+
'ppu', 'ise', ')', '?', 'I', 'ca', 'n\'t', 'do', '!', 'i',
287+
'\'ll', '\'ve', 'to', 'do', '!', 'nge', '!', 'I.', 'K.', 'ral',
288+
'who', 'am', 'I', '?', '🎭', ',', '[', '🧞', '[', 'bbu',
289+
'(', 'eft', ')', '(', 'OOV', ')', 'rch', '12', ',', '998',
290+
'ail', 'ess', '-16', 'vbn', '-', 'fgh', '.K.', 'ena', '.', 'ess',
291+
'ing', 'is', 'ome', '.', 'Mr.', '.K.', 'ena', 'aaa', '.', '-',
292+
'bbb', '431', '452'
293+
];
294+
295+
const types = [
296+
'emoji', 'word', 'punctuation', 'emoticon', 'emoji',
297+
'emoji', 'tabCRLF', 'email', 'punctuation', 'word',
298+
'punctuation', 'word', 'word', 'symbol', 'word',
299+
'punctuation', 'symbol', 'url', 'hashtag', 'word',
300+
'word', 'word', 'word', 'punctuation', 'symbol',
301+
'punctuation', 'decade', 'punctuation', 'symbol', 'punctuation',
302+
'punctuation', 'word', 'punctuation', 'word', 'punctuation',
303+
'punctuation', 'punctuation', 'word', 'punctuation', 'word',
304+
'word', 'word', 'word', 'punctuation', 'word',
305+
'punctuation', 'word', 'word', 'word', 'punctuation',
306+
'word', 'word', 'punctuation', 'punctuation', 'word',
307+
'word', 'word', 'word', 'punctuation', 'word',
308+
'word', 'word', 'word', 'word', 'punctuation',
309+
'word', 'punctuation', 'word', 'word', 'word',
310+
'word', 'word', 'word', 'punctuation', 'emoji',
311+
'punctuation', 'punctuation', 'emoji', 'punctuation', 'word',
312+
'punctuation', 'word', 'punctuation', 'punctuation', 'word',
313+
'punctuation', 'word', 'number', 'punctuation', 'number',
314+
'word', 'word', 'word', 'word', 'punctuation',
315+
'word', 'word', 'word', 'punctuation', 'word',
316+
'word', 'word', 'word', 'punctuation', 'word',
317+
'word', 'word', 'word', 'punctuation', 'punctuation',
318+
'word', 'number', 'word'
319+
];
320+
321+
const precedingSpaces = [
322+
'', '', '', '', ' ', '', ' ', ' ', ' ', '', '', ' ',
323+
'', ' ', '', '', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
324+
'', ' ', ' ', '', ' ', '', ' ', '', '', '', '', ' ',
325+
'', '', '', ' ', ' ', ' ', ' ', ' ', ' ', '', ' ', ' ',
326+
' ', ' ', '', ' ', '', '', ' ', ' ', '', ' ', '', ' ',
327+
'', '', ' ', ' ', '', ' ', '', ' ', ' ', ' ', ' ', ' ',
328+
' ', '', ' ', '', ' ', '', ' ', '', ' ', '', '', ' ',
329+
'', '', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', '', '',
330+
' ', '', '', '', ' ', ' ', ' ', '', ' ', '', ' ', ' ',
331+
'', '', '', ' ', ''
332+
];
333+
334+
const shapes = [
335+
'🎭', 'Xx.', '-', ':)',
336+
'🎉', '🎉', '\n', '[email protected]',
337+
'(', 'X.X.X.', ')', 'X.X.X',
338+
'\'x', '*', 'xxxx', '.',
339+
'*', 'xxxx://xxxx.xxx', '#xxxx', 'X',
340+
'xxx', 'xxx', 'xx', '(',
341+
'*', '-', '\'ddx', '-',
342+
'*', ')', '\'', 'xxx',
343+
'/', 'xx', ')', '-',
344+
'\'', 'xxxx', '\'', 'Xxxxx',
345+
'xxxx', 'xx', 'xxxx', '—',
346+
'XxXxXx', '.', 'Xxxxx', 'xx',
347+
'Xxxxx', '(', 'xxxx', 'xxxx',
348+
')', '?', 'X', 'xx',
349+
'x\'x', 'xx', '!', 'x',
350+
'\'xx', '\'xx', 'xx', 'xx',
351+
'!', 'Xxxxx', '!', 'X.',
352+
'X.', 'Xxxxx', 'xxx', 'xx',
353+
'X', '?', '🎭', ',',
354+
'[', '🧞', '[', 'Xxxxx',
355+
'(', 'xxxx', ')', '(',
356+
'XXX', ')', 'Xxxxx', 'dd',
357+
',', 'dddd', 'x-xxxx', 'xxxx-xxxx',
358+
'X-dd', 'xxxx', '-', 'xxxx',
359+
'X.X.', 'Xxxxx', '.', 'Xxxxx-xxxx',
360+
'xxxx', 'xx', 'xxxx', '.',
361+
'Xx.', 'X.X.', 'Xxxxx', 'xxx',
362+
'.', '-', 'xxx', 'dddd',
363+
'xxxxdddd'
364+
];
365+
366+
const cases = [
367+
'other', 'titleCase', 'other', 'other', 'other', 'other',
368+
'other', 'other', 'other', 'upperCase', 'other', 'upperCase',
369+
'other', 'other', 'lowerCase', 'other', 'other', 'other',
370+
'other', 'upperCase', 'lowerCase', 'lowerCase', 'lowerCase', 'other',
371+
'other', 'other', 'other', 'other', 'other', 'other',
372+
'other', 'lowerCase', 'other', 'lowerCase', 'other', 'other',
373+
'other', 'lowerCase', 'other', 'titleCase', 'lowerCase', 'lowerCase',
374+
'lowerCase', 'other', 'other', 'other', 'titleCase', 'lowerCase',
375+
'titleCase', 'other', 'lowerCase', 'lowerCase', 'other', 'other',
376+
'upperCase', 'lowerCase', 'other', 'lowerCase', 'other', 'lowerCase',
377+
'other', 'other', 'lowerCase', 'lowerCase', 'other', 'titleCase',
378+
'other', 'upperCase', 'upperCase', 'titleCase', 'lowerCase', 'lowerCase',
379+
'upperCase', 'other', 'other', 'other', 'other', 'other',
380+
'other', 'titleCase', 'other', 'lowerCase', 'other', 'other',
381+
'upperCase', 'other', 'titleCase', 'other', 'other', 'other',
382+
'lowerCase', 'lowerCase', 'other', 'lowerCase', 'other', 'lowerCase',
383+
'upperCase', 'titleCase', 'other', 'titleCase', 'lowerCase', 'lowerCase',
384+
'lowerCase', 'other', 'titleCase', 'upperCase', 'titleCase', 'lowerCase',
385+
'other', 'other', 'lowerCase', 'other', 'other'
386+
];
387+
150388
var doc = nlp.readDoc( sentence );
389+
390+
// Test what is going to be diplayed!
391+
expect( doc.tokens().out() ).to.deep.equal( tokens );
392+
expect( doc.tokens().out( its.prefix ) ).to.deep.equal( prefixes );
393+
expect( doc.tokens().out( its.suffix ) ).to.deep.equal( suffixes );
394+
expect( doc.tokens().out( its.type ) ).to.deep.equal( types );
395+
expect( doc.tokens().out( its.precedingSpaces ) ).to.deep.equal( precedingSpaces );
396+
expect( doc.tokens().out( its.shape ) ).to.deep.equal( shapes );
397+
expect( doc.tokens().out( its.case ) ).to.deep.equal( cases );
151398
// Visual display.
152399
doc.printTokens();
153400
} );

0 commit comments

Comments
 (0)